const remote = {
  'traceId': '060093a6172139626123635272066',
  'errorMessage': null,
  'errorCode': null,
  'success': true,
  'data': [
    {
      'id': 100008,
      'nodeInstanceId': '1',
      'flowItem': 'GENERATE_CODE',
      'flowItemName': '生成代码',
      'flowStatus': 'PROCESSING',
      'flowContent':
        '[{"fileName":"DrmQueryController.java","filePath":"app/web/src/main/java/com/alipay/archcompass/web/controller/invalidanalysis/DrmQueryController.java","newCode":"@GetMapping(value = \\"/queryInvalidDrmTree\\")\\n    public ArchCompassResponse queryInvalidDrmTree(String reportId, String dataId) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<DrmResultInfo>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n                ParamCheckHelper.notBlank(reportId, \\"reportId\\");\\n            }\\n\\n            @Override\\n            public DrmResultInfo process() {\\n\\n                AppDrmAnalysisTransactionMO queryAppDrmAnalysisTransactionMO = new AppDrmAnalysisTransactionMO();\\n                queryAppDrmAnalysisTransactionMO.setInvalidFlag(\\"Y\\");\\n                queryAppDrmAnalysisTransactionMO.setInvalidDesc(\\"FULL\\"); // Assuming \'FULL\' as default when flag is removed\\n                queryAppDrmAnalysisTransactionMO.setReportId(reportId);\\n                queryAppDrmAnalysisTransactionMO.setDataId(dataId);\\n                queryAppDrmAnalysisTransactionMO.setAnalysisStatus(AnalysisStatusEnum.COMPLETED.getCode());\\n\\n                List<AppDrmAnalysisTransactionMO> dbDrmInfo = appDrmAnalysisTransactionRepository.queryByReportIdAndReference(\\n                        queryAppDrmAnalysisTransactionMO);\\n                if (CollectionUtils.isEmpty(dbDrmInfo)) {\\n                    return null;\\n                }\\n\\n                //... (rest of the code remains unchanged)\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmTree\\");\\n    }\\n","newFullCode":"/*\\n * Ant Group\\n * Copyright (c) 2004-2023 All Rights Reserved.\\n */\\npackage com.alipay.archcompass.web.controller.invalidanalysis;\\n\\nimport com.alibaba.common.lang.StringUtil;\\nimport com.alibaba.fastjson.JSON;\\nimport com.alipay.archcompass.common.dal.transaction.auto.dataobject.AppDrmAnalysisDetailDO;\\nimport com.alipay.archcompass.common.dal.transaction.auto.dataobject.AppDrmAnalysisTransactionDO;\\nimport com.alipay.archcompass.common.dal.transaction.auto.dataobject.AppDrmInfoDO;\\nimport com.alipay.archcompass.common.facade.response.ArchCompassResponse;\\nimport com.alipay.archcompass.common.service.integration.codebase.CodebaseClient;\\nimport com.alipay.archcompass.common.service.integration.codebase.result.CodeContentLineData;\\nimport com.alipay.archcompass.common.service.integration.codeinsight.CodeInsightClient;\\nimport com.alipay.archcompass.common.service.integration.codeinsight.request.CodeInsightRequest;\\nimport com.alipay.archcompass.common.service.integration.codeinsight.request.PatchData;\\nimport com.alipay.archcompass.common.service.integration.drm.DrmConfig;\\nimport com.alipay.archcompass.common.util.DateUtil;\\nimport com.alipay.archcompass.core.model.common.ArchCompassServiceCallBack;\\nimport com.alipay.archcompass.core.model.common.ArchCompassServiceTemplate;\\nimport com.alipay.archcompass.core.model.common.check.ParamCheckHelper;\\nimport com.alipay.archcompass.core.model.constant.RequestConstant;\\nimport com.alipay.archcompass.core.model.domain.AppDrmAnalysisDetailMO;\\nimport com.alipay.archcompass.core.model.domain.AppDrmAnalysisTransactionMO;\\nimport com.alipay.archcompass.core.model.domain.AppDrmClassDetailMO;\\nimport com.alipay.archcompass.core.model.domain.AppDrmInfoMO;\\nimport com.alipay.archcompass.core.model.domain.DrmSummaryInfo;\\nimport com.alipay.archcompass.core.model.domain.analysis.AnalysisBatchCondition;\\nimport com.alipay.archcompass.core.model.domain.drm.DrmAttribute;\\nimport com.alipay.archcompass.core.model.domain.drm.DrmDigestInfo;\\nimport com.alipay.archcompass.core.model.domain.drm.DrmResultInfo;\\nimport com.alipay.archcompass.core.model.domain.drm.DrmTree;\\nimport com.alipay.archcompass.core.model.domain.drm.InValidMethodSummary;\\nimport com.alipay.archcompass.core.model.enums.AnalysisStatusEnum;\\nimport com.alipay.archcompass.core.model.response.PageQueryResult;\\nimport com.alipay.archcompass.core.service.AnalysisBatchConditionRepository;\\nimport com.alipay.archcompass.core.service.AppDrmAnalysisDetailRepository;\\nimport com.alipay.archcompass.core.service.AppDrmAnalysisTransactionRepository;\\nimport com.alipay.archcompass.core.service.AppDrmRecordRepository;\\nimport com.alipay.archcompass.core.service.convertor.AppDrmAnalysisDetailConvertor;\\nimport com.alipay.archcompass.core.service.convertor.AppDrmAnalysisTransactionConvertor;\\nimport com.alipay.archcompass.core.service.convertor.AppDrmInfoConvertor;\\nimport com.alipay.sofa.runtime.api.annotation.SofaReference;\\nimport com.github.difflib.DiffUtils;\\nimport com.github.difflib.UnifiedDiffUtils;\\nimport com.github.difflib.patch.Patch;\\nimport com.iwallet.biz.common.util.PageList;\\nimport org.springframework.context.annotation.Scope;\\nimport org.springframework.util.CollectionUtils;\\nimport org.springframework.web.bind.annotation.GetMapping;\\nimport org.springframework.web.bind.annotation.PostMapping;\\nimport org.springframework.web.bind.annotation.RequestBody;\\nimport org.springframework.web.bind.annotation.RequestMapping;\\nimport org.springframework.web.bind.annotation.RestController;\\n\\nimport java.util.ArrayList;\\nimport java.util.Calendar;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.Date;\\nimport java.util.HashMap;\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.stream.Collectors;\\n\\n/**\\n * @author John\\n * @version DrmQueryController.java, v 0.1 2023年10月11日 11:06 John\\n */\\n@RestController\\n@Scope(value = \\"prototype\\")\\n@RequestMapping(value = RequestConstant.WEB_API)\\npublic class DrmQueryController {\\n\\n    @SofaReference\\n    private AppDrmRecordRepository appDrmRecordRepository;\\n\\n    @SofaReference\\n    private AppDrmAnalysisTransactionRepository appDrmAnalysisTransactionRepository;\\n\\n    @SofaReference\\n    private AppDrmAnalysisDetailRepository appDrmAnalysisDetailRepository;\\n\\n    @SofaReference\\n    private CodebaseClient codebaseClient;\\n\\n    @SofaReference\\n    private CodeInsightClient codeInsightClient;\\n\\n    @SofaReference\\n    private AnalysisBatchConditionRepository analysisBatchConditionRepository;\\n\\n    @SofaReference\\n    private DrmConfig drmConfig;\\n\\n    @PostMapping(value = \\"/queryDrmDataByPushRecord\\")\\n    public ArchCompassResponse queryDrmDataByPushRecord(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<PageQueryResult>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n                ParamCheckHelper.notBlank(drmQueryRequest.getAppName(), \\"appName\\");\\n                ParamCheckHelper.notBlank(drmQueryRequest.getTimeInterval(), \\"timeRange\\");\\n            }\\n\\n            @Override\\n            public PageQueryResult process() {\\n                Date date = null;\\n                if (StringUtil.isEmpty(drmQueryRequest.getActualTime())) {\\n                    int numberOfMonths = Integer.valueOf(drmQueryRequest.getTimeInterval());\\n\\n                    Calendar calendar = Calendar.getInstance();\\n                    calendar.add(Calendar.MONTH, -numberOfMonths);\\n\\n                    date = calendar.getTime();\\n                } else {\\n                    date = DateUtil.getDateTime(drmQueryRequest.getActualTime());\\n                }\\n                PageList pageList = appDrmRecordRepository.queryDrmDataByAppNameAndPushTimeForPage(drmQueryRequest.getAppName(), drmQueryRequest.getDataId(), date,\\n                        drmQueryRequest.getPageSize(), drmQueryRequest.getCurrentPage());\\n\\n                PageQueryResult pageQueryResult = new PageQueryResult();\\n                pageQueryResult.setPageSize(drmQueryRequest.getPageSize());\\n                pageQueryResult.setCurrentPage(drmQueryRequest.getCurrentPage());\\n                if (pageList != null && pageList.size() != 0) {\\n                    pageQueryResult.setTotal(pageList.getPaginator().getItems());\\n                    List<AppDrmInfoMO> appDrmInfoMOList = AppDrmInfoConvertor.convertToMOList(\\n                            JSON.parseArray(JSON.toJSONString(pageList), AppDrmInfoDO.class));\\n                    pageQueryResult.setResult(appDrmInfoMOList);\\n\\n                }\\n                return pageQueryResult;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryDrmDataByPushRecord\\");\\n\\n    }\\n\\n    @GetMapping(value = \\"/queryInvalidDrmTree\\")\\n    public ArchCompassResponse queryInvalidDrmTree(String reportId, String dataId) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<DrmResultInfo>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n                ParamCheckHelper.notBlank(reportId, \\"reportId\\");\\n            }\\n\\n            @Override\\n            public DrmResultInfo process() {\\n\\n                AppDrmAnalysisTransactionMO queryAppDrmAnalysisTransactionMO = new AppDrmAnalysisTransactionMO();\\n                queryAppDrmAnalysisTransactionMO.setInvalidFlag(\\"Y\\");\\n                queryAppDrmAnalysisTransactionMO.setInvalidDesc(\\"FULL\\"); // Assuming \'FULL\' as default when flag is removed\\n                queryAppDrmAnalysisTransactionMO.setReportId(reportId);\\n                queryAppDrmAnalysisTransactionMO.setDataId(dataId);\\n                queryAppDrmAnalysisTransactionMO.setAnalysisStatus(AnalysisStatusEnum.COMPLETED.getCode());\\n\\n                List<AppDrmAnalysisTransactionMO> dbDrmInfo = appDrmAnalysisTransactionRepository.queryByReportIdAndReference(\\n                        queryAppDrmAnalysisTransactionMO);\\n                if (CollectionUtils.isEmpty(dbDrmInfo)) {\\n                    return null;\\n                }\\n\\n                //... (rest of the code remains unchanged)\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmTree\\");\\n    }\\n\\n    @GetMapping(value = \\"/queryInvalidDrmAssetAnalysisSummary\\")\\n    public ArchCompassResponse queryInvalidDrmAssetAnalysisSummary(String reportId) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<Map<String, Object>>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n                ParamCheckHelper.notBlank(reportId, \\"reportId\\");\\n            }\\n\\n            @Override\\n            public Map<String, Object> process() {\\n\\n                List<AppDrmAnalysisTransactionMO> drmAnalysisTransactionMOList\\n                        = appDrmAnalysisTransactionRepository.queryByReportId(reportId);\\n                if (CollectionUtils.isEmpty(drmAnalysisTransactionMOList)) {\\n                    return null;\\n                }\\n\\n                int totalCount = drmAnalysisTransactionMOList.size();\\n                int successCount = 0;\\n                int failCount = 0;\\n                int directReferenceCount = 0;\\n                int inDirectReferenceCount = 0;\\n                int invalidDrmCount = 0;\\n                int fullInvalidDrmCount = 0;\\n                int partInvalidDrmCount = 0;\\n                for (AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO : drmAnalysisTransactionMOList) {\\n                    if (AnalysisStatusEnum.COMPLETED.getCode().equals(appDrmAnalysisTransactionMO.getAnalysisStatus())) {\\n                        successCount += 1;\\n                        //成功的数据里获取无效的DRM总数量\\n                        if (\\"Y\\".equals(appDrmAnalysisTransactionMO.getInvalidFlag())) {\\n                            invalidDrmCount += 1;\\n                        }\\n                        if (\\"Y\\".equals(appDrmAnalysisTransactionMO.getInvalidFlag()) && \\"FULL\\".equals(\\n                                appDrmAnalysisTransactionMO.getInvalidDesc())) {\\n                            fullInvalidDrmCount += 1;\\n                        }\\n                        if (\\"Y\\".equals(appDrmAnalysisTransactionMO.getInvalidFlag()) && \\"PART\\".equals(\\n                                appDrmAnalysisTransactionMO.getInvalidDesc())) {\\n                            partInvalidDrmCount += 1;\\n\\n                        }\\n                    }\\n                    if (AnalysisStatusEnum.FAILED.getCode().equals(appDrmAnalysisTransactionMO.getAnalysisStatus())) {\\n                        failCount += 1;\\n                    }\\n                    if (\\"Y\\".equals(appDrmAnalysisTransactionMO.getReferenceFlag())) {\\n                        directReferenceCount += 1;\\n                    }\\n                    if (\\"N\\".equals(appDrmAnalysisTransactionMO.getReferenceFlag())) {\\n                        inDirectReferenceCount += 1;\\n                    }\\n                }\\n\\n                //获取有直接引用的dataId集合\\n                List<String> dataIdList = drmAnalysisTransactionMOList.stream().filter(data -> data.getReferenceFlag().equals(\\"Y\\")).map(\\n                        AppDrmAnalysisTransactionMO::getDataId).collect(\\n                        Collectors.toList());\\n                int relateClassCount = 0;\\n                if (!CollectionUtils.isEmpty(dataIdList)) {\\n                    relateClassCount = appDrmAnalysisDetailRepository.queryByReportIdAndDataIdList(reportId, dataIdList);\\n\\n                }\\n                //List<AnalysisBatchCondition> analysisBatchConditionList = analysisBatchConditionRepository.queryByBatchId\\n                // (drmAnalysisTransactionMOList.get(0).getBatchId());\\n                //String configId = analysisBatchConditionList.get(0).getChangeItemId();\\n\\n                DrmDigestInfo drmDigestInfo = new DrmDigestInfo();\\n\\n                Map<String, String> paramMap = drmConfig.getAppNameConfigIdMap();\\n                if (null == paramMap || paramMap.size() == 0) {\\n                    drmDigestInfo.setCoverageReportUrl(\\"\\");\\n                } else if (null != paramMap.get(drmAnalysisTransactionMOList.get(0).getAppName())) {\\n                    drmDigestInfo.setCoverageReportUrl(\\n                            \\"https://compassprod.alipay.com/config/report/reportDetail?type=OVERALL&configId=\\" + paramMap.get(\\n                                    drmAnalysisTransactionMOList.get(0).getAppName()));\\n                } else {\\n                    drmDigestInfo.setCoverageReportUrl(\\"\\");\\n                }\\n                drmDigestInfo.setFailCount(failCount);\\n                drmDigestInfo.setDirectReferenceCount(directReferenceCount);\\n                drmDigestInfo.setInDirectReferenceCount(inDirectReferenceCount);\\n                drmDigestInfo.setSuccessCount(successCount);\\n                drmDigestInfo.setTotalCount(totalCount);\\n                drmDigestInfo.setCommitId(drmAnalysisTransactionMOList.get(0).getCommitId());\\n                drmDigestInfo.setRelateClassCount(relateClassCount);\\n                drmDigestInfo.setInvalidDrmCount(invalidDrmCount);\\n                drmDigestInfo.setValidDrmCount(successCount - invalidDrmCount);\\n                drmDigestInfo.setFullInvalidDrmCount(fullInvalidDrmCount);\\n                drmDigestInfo.setPartInvalidDrmCount(partInvalidDrmCount);\\n\\n                Map<String, Object> map = new HashMap<>();\\n                map.put(\\"reportId\\", reportId);\\n                map.put(\\"summary\\", drmDigestInfo);\\n                return map;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmAssetAnalysisSummary\\");\\n\\n    }\\n\\n    @PostMapping(value = \\"/queryInvalidDrmClassList\\")\\n    public ArchCompassResponse queryInvalidDrmClassList(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<PageQueryResult>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public PageQueryResult process() {\\n                //先不做报错处理，直接返回null\\n                if (StringUtil.isEmpty(drmQueryRequest.getDataId())) {\\n                    return null;\\n                }\\n\\n                //根据报告ID查询出应用名等信息来\\n                AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO = appDrmAnalysisTransactionRepository.queryByReportIdAndDataId(\\n                        drmQueryRequest.getReportId(), drmQueryRequest.getDataId());\\n\\n                String configId = \\"\\";\\n                Map<String, String> paramMap = drmConfig.getAppNameConfigIdMap();\\n\\n                if (!paramMap.isEmpty() && null != paramMap.get(appDrmAnalysisTransactionMO.getAppName())) {\\n                    configId = paramMap.get(appDrmAnalysisTransactionMO.getAppName());\\n                }\\n\\n                PageList pageList = appDrmAnalysisDetailRepository.queryDataForPage(drmQueryRequest.getReportId(),\\n                        drmQueryRequest.getDataId(), drmQueryRequest.getClassName(), drmQueryRequest.getInvalidFlag(),\\n                        drmQueryRequest.getPageSize(), drmQueryRequest.getCurrentPage());\\n\\n                PageQueryResult pageQueryResult = new PageQueryResult();\\n                pageQueryResult.setPageSize(drmQueryRequest.getPageSize());\\n                pageQueryResult.setCurrentPage(drmQueryRequest.getCurrentPage());\\n                if (pageList != null && pageList.size() != 0) {\\n                    pageQueryResult.setTotal(pageList.getPaginator().getItems());\\n                    List<AppDrmClassDetailMO> appDrmClassDetailMOList = AppDrmAnalysisDetailConvertor.convertToClassMOList(\\n                            JSON.parseArray(JSON.toJSONString(pageList), AppDrmAnalysisDetailDO.class), configId);\\n                    pageQueryResult.setResult(appDrmClassDetailMOList);\\n\\n                }\\n                return pageQueryResult;\\n\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmClassList\\");\\n\\n    }\\n\\n    @PostMapping(value = \\"/queryInvalidDrmClassContent\\")\\n    public ArchCompassResponse queryInvalidDrmClassContent(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<List<CodeContentLineData>>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public List<CodeContentLineData> process() {\\n\\n                AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO = appDrmAnalysisTransactionRepository.queryByReportIdAndDataId(\\n                        drmQueryRequest.getReportId(), drmQueryRequest.getDataId());\\n\\n                List<CodeContentLineData> codeContentLineDataList = codebaseClient.queryCodeFileContent(\\n                        appDrmAnalysisTransactionMO.getRepoUrl(), \\"\\", appDrmAnalysisTransactionMO.getCommitId(),\\n                        drmQueryRequest.getFilePath());\\n\\n                if (CollectionUtils.isEmpty(codeContentLineDataList)) {\\n                    return null;\\n                }\\n\\n                AppDrmAnalysisDetailMO appDrmAnalysisDetailMO = appDrmAnalysisDetailRepository.queryByReportIdAndDataIdAndFilePath(\\n                        drmQueryRequest.getReportId(), drmQueryRequest.getDataId(), drmQueryRequest.getFilePath());\\n                List<InValidMethodSummary> inValidMethodSummaryList = JSON.parseArray(appDrmAnalysisDetailMO.getRefFileDetail(),\\n                        InValidMethodSummary.class);\\n\\n                //从里面取出存在无效标记的数据\\n                List<Integer> coverCodeLineList = new ArrayList<>();\\n                List<Integer> unCoverCodeLineList = new ArrayList<>();\\n\\n                //覆盖行 标记绿色 未覆盖行 标记红色\\n                for (InValidMethodSummary inValidMethodSummary : inValidMethodSummaryList) {\\n                    if (\\"Y\\".equals(inValidMethodSummary.getInValidFlag())) {\\n                        if (!CollectionUtils.isEmpty(inValidMethodSummary.getCoverCodeLineList())) {\\n                            coverCodeLineList.addAll(inValidMethodSummary.getCoverCodeLineList());\\n                        }\\n                        if (!CollectionUtils.isEmpty(inValidMethodSummary.getUnCoverCodeLineList())) {\\n                            unCoverCodeLineList.addAll(inValidMethodSummary.getUnCoverCodeLineList());\\n                        }\\n                    }\\n                }\\n                for (CodeContentLineData codeContentLineData : codeContentLineDataList) {\\n                    codeContentLineData.setLineNumber(codeContentLineData.getLineNumber() + 1);\\n                    //进行染色\\n                    if (unCoverCodeLineList.contains(codeContentLineData.getLineNumber())) {\\n                        codeContentLineData.setLineColor(\\"RED\\");\\n                    }\\n\\n                }\\n                return codeContentLineDataList;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmClassContent\\");\\n\\n    }\\n\\n    @PostMapping(value = \\"/createCodeComments\\")\\n    public ArchCompassResponse createCodeComments(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<String>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public String process() {\\n\\n                AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO = appDrmAnalysisTransactionRepository.queryByReportIdAndDataId(\\n                        drmQueryRequest.getReportId(), drmQueryRequest.getDataId());\\n\\n                List<PatchData> patchDataList = new ArrayList<>();\\n\\n                CodeInsightRequest codeInsightRequest = new CodeInsightRequest();\\n                codeInsightRequest.setBranch(\\"master\\");\\n                codeInsightRequest.setCommit(appDrmAnalysisTransactionMO.getCommitId());\\n                codeInsightRequest.setCommitMsg(\\"自动标注无效代码块\\");\\n                codeInsightRequest.setRepoUrl(appDrmAnalysisTransactionMO.getRepoUrl());\\n\\n                String commentUrl = \\"\\";\\n                if (StringUtil.isEmpty(drmQueryRequest.getFilePath())) {\\n                    List<AppDrmAnalysisDetailMO> appDrmAnalysisDetailMOList = appDrmAnalysisDetailRepository.queryByReportIdAndDataId(\\n                            drmQueryRequest.getReportId(), drmQueryRequest.getDataId(), \\"Y\\");\\n                    for (AppDrmAnalysisDetailMO appDrmAnalysisDetailMO : appDrmAnalysisDetailMOList) {\\n                        PatchData patchData = handleCommentUrl(appDrmAnalysisTransactionMO, appDrmAnalysisDetailMO.getRefFilePath(),\\n                                appDrmAnalysisDetailMO.getRefFileDetail());\\n                        if (null != patchData) {\\n                            patchDataList.add(patchData);\\n                        }\\n                    }\\n                    codeInsightRequest.setPatches(patchDataList);\\n\\n                    commentUrl = codeInsightClient.createCodeComments(codeInsightRequest);\\n\\n                    appDrmAnalysisTransactionMO.setCommentUrl(commentUrl);\\n                    appDrmAnalysisTransactionMO.setCommentFlag(\\"Y\\");\\n                    appDrmAnalysisTransactionRepository.updateCommentInfoByReportIdAndDataId(appDrmAnalysisTransactionMO);\\n\\n                    //更新标注记录\\n                    AppDrmAnalysisDetailMO updateAppDrmAnalysisDetailMO = new AppDrmAnalysisDetailMO();\\n                    updateAppDrmAnalysisDetailMO.setReportId(drmQueryRequest.getReportId());\\n                    updateAppDrmAnalysisDetailMO.setDataId(drmQueryRequest.getDataId());\\n                    updateAppDrmAnalysisDetailMO.setCommentUrl(commentUrl);\\n                    updateAppDrmAnalysisDetailMO.setCommentFlag(\\"Y\\");\\n                    appDrmAnalysisDetailRepository.updateByReportIdAndDataIdAndFilePath(updateAppDrmAnalysisDetailMO);\\n\\n                } else {\\n                    AppDrmAnalysisDetailMO appDrmAnalysisDetailMO = appDrmAnalysisDetailRepository.queryByReportIdAndDataIdAndFilePath(\\n                            drmQueryRequest.getReportId(), drmQueryRequest.getDataId(), drmQueryRequest.getFilePath());\\n                    PatchData patchData = handleCommentUrl(appDrmAnalysisTransactionMO, appDrmAnalysisDetailMO.getRefFilePath(),\\n                            appDrmAnalysisDetailMO.getRefFileDetail());\\n                    if (null != patchData) {\\n                        patchDataList.add(patchData);\\n                    }\\n                    codeInsightRequest.setPatches(patchDataList);\\n\\n                    commentUrl = codeInsightClient.createCodeComments(codeInsightRequest);\\n                    //更新标注记录\\n                    appDrmAnalysisDetailMO.setCommentUrl(commentUrl);\\n                    appDrmAnalysisDetailMO.setCommentFlag(\\"Y\\");\\n                    appDrmAnalysisDetailRepository.updateByReportIdAndDataIdAndFilePath(appDrmAnalysisDetailMO);\\n\\n                    //有且仅有一个的话，直接把流水表也标注了\\n                    if (!StringUtil.isEmpty(appDrmAnalysisTransactionMO.getMemo())) {\\n                        DrmSummaryInfo drmSummaryInfo = JSON.parseObject(appDrmAnalysisTransactionMO.getMemo(), DrmSummaryInfo.class);\\n                        if (1 == drmSummaryInfo.getInvalidReferenceClassNum()) {\\n                            appDrmAnalysisTransactionMO.setCommentUrl(commentUrl);\\n                            appDrmAnalysisTransactionMO.setCommentFlag(\\"Y\\");\\n                            appDrmAnalysisTransactionRepository.updateCommentInfoByReportIdAndDataId(appDrmAnalysisTransactionMO);\\n\\n                        }\\n\\n                    }\\n                }\\n\\n                return commentUrl;\\n            }\\n\\n            private PatchData handleCommentUrl(AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO, String filePath,\\n                                               String fileDetail) {\\n                List<CodeContentLineData> codeContentLineDataList = codebaseClient.queryCodeFileContent(\\n                        appDrmAnalysisTransactionMO.getRepoUrl(), \\"master\\", appDrmAnalysisTransactionMO.getCommitId(), filePath);\\n\\n                List<String> sourceFileContentList = new ArrayList<>();\\n                List<String> targetFileContentList = new ArrayList<>();\\n\\n                List<InValidMethodSummary> methodSummaryList = JSON.parseArray(fileDetail, InValidMethodSummary.class);\\n                List<Integer> inValidMethodLineList = new ArrayList<>();\\n                for (InValidMethodSummary inValidMethodSummary : methodSummaryList) {\\n                    if (\\"Y\\".equals(inValidMethodSummary.getInValidFlag()) && !CollectionUtils.isEmpty(\\n                            inValidMethodSummary.getUnCoverCodeLineList())) {\\n                        inValidMethodLineList.addAll(inValidMethodSummary.getUnCoverCodeLineList());\\n                    }\\n                }\\n                if (CollectionUtils.isEmpty(inValidMethodLineList)) {\\n                    return null;\\n                }\\n                //Map<Integer, List<Integer>> resultMap = splitLineMapData(inValidMethodLineList);\\n\\n                for (CodeContentLineData codeContentLineData : codeContentLineDataList) {\\n                    codeContentLineData.setLineNumber(codeContentLineData.getLineNumber() + 1);\\n                    sourceFileContentList.add(codeContentLineData.getLineContent());\\n                    //if (inValidMethodLineList.contains(codeContentLineData.getLineNumber())) {\\n                    //    continue;\\n                    //}\\n                    //targetFileContentList.add(codeContentLineData.getLineContent());\\n                    //匹配到行号数据后\\n                    if (inValidMethodLineList.contains(codeContentLineData.getLineNumber())) {\\n                        String content = codeContentLineData.getLineContent()\\n                                + \\"//the current code line is not covered by production traffic\\";\\n                        targetFileContentList.add(content);\\n\\n                        //List<Integer> lineNumberList = resultMap.get(codeContentLineData.getLineNumber());\\n                        //if (!CollectionUtils.isEmpty(lineNumberList)) {\\n                        //    String content;\\n                        //    if (lineNumberList.size() == 1) {\\n                        //        content = codeContentLineData.getLineContent()\\n                        //                + \\" //The current code line is not covered by production traffic\\";\\n                        //    } else {\\n                        //        content = codeContentLineData.getLineContent()\\n                        //                + \\" //The code from lines \\" + lineNumberList.get(0) + \\" to \\" + lineNumberList.get(\\n                        //                lineNumberList.size() - 1) + \\" is not covered by production traffic\\";\\n                        //    }\\n                        //\\n                        //    targetFileContentList.add(content);\\n                    } else {\\n                        targetFileContentList.add(codeContentLineData.getLineContent());\\n                    }\\n                }\\n                if (CollectionUtils.isEmpty(sourceFileContentList) || CollectionUtils.isEmpty(targetFileContentList)) {\\n                    return null;\\n                }\\n\\n                Patch<String> patch = DiffUtils.diff(sourceFileContentList, targetFileContentList);\\n\\n                List<String> unifiedDiff = UnifiedDiffUtils.generateUnifiedDiff(\\"\\", \\"\\", sourceFileContentList, patch, 1);\\n\\n                String rawPatch = String.join(\\"\\\\n\\", unifiedDiff.subList(2, unifiedDiff.size()));\\n                String rawPatchStr = String.format(\\"--- \\\\n+++ \\\\n%s\\", rawPatch);\\n\\n                PatchData patchData = new PatchData();\\n                patchData.setPatch(rawPatchStr);\\n                patchData.setPath(filePath);\\n                return patchData;\\n\\n            }\\n\\n            //private Map<Integer, List<Integer>> splitLineMapData(List<Integer> inValidMethodLineList) {\\n            //\\n            //    Map<Integer, List<Integer>> groupedMap = new LinkedHashMap<>();\\n            //    int currentGroupStart = inValidMethodLineList.get(0);\\n            //    List<Integer> currentGroup = new ArrayList<>();\\n            //    currentGroup.add(currentGroupStart);\\n            //\\n            //    for (int i = 1; i < inValidMethodLineList.size(); i++) {\\n            //        int currentNumber = inValidMethodLineList.get(i);\\n            //        int previousNumber = inValidMethodLineList.get(i - 1);\\n            //\\n            //        if (currentNumber - previousNumber == 1) {\\n            //            currentGroup.add(currentNumber);\\n            //        } else {\\n            //            groupedMap.put(currentGroupStart, currentGroup);\\n            //            currentGroupStart = currentNumber;\\n            //            currentGroup = new ArrayList<>();\\n            //            currentGroup.add(currentGroupStart);\\n            //        }\\n            //    }\\n            //\\n            //    groupedMap.put(currentGroupStart, currentGroup);\\n            //    return groupedMap;\\n            //\\n            //}\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"createCodeComments\\");\\n\\n    }\\n\\n    @PostMapping(value = \\"/queryUnDirectReferenceDrmData\\")\\n    public ArchCompassResponse queryUnDirectReferenceDrmData(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<PageQueryResult>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public PageQueryResult process() {\\n\\n                PageList pageList = appDrmAnalysisTransactionRepository.queryByReportIdAndReferenceForPage(drmQueryRequest.getReportId(),\\n                        drmQueryRequest.getDataId(), \\"N\\", \\"\\", \\"\\", drmQueryRequest.getPageSize(), drmQueryRequest.getCurrentPage());\\n\\n                PageQueryResult pageQueryResult = new PageQueryResult();\\n                pageQueryResult.setPageSize(drmQueryRequest.getPageSize());\\n                pageQueryResult.setCurrentPage(drmQueryRequest.getCurrentPage());\\n                if (pageList != null && pageList.size() != 0) {\\n                    pageQueryResult.setTotal(pageList.getPaginator().getItems());\\n                    List<AppDrmAnalysisTransactionMO> appDrmAnalysisTransactionMOList\\n                            = AppDrmAnalysisTransactionConvertor.convertToMOList(\\n                            JSON.parseArray(JSON.toJSONString(pageList), AppDrmAnalysisTransactionDO.class));\\n                    pageQueryResult.setResult(appDrmAnalysisTransactionMOList);\\n\\n                }\\n                return pageQueryResult;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryUnDirectReferenceDrmData\\");\\n\\n    }\\n\\n    /**\\n     * 查询分析失败的DRM数据\\n     *\\n     * @param drmQueryRequest\\n     * @return\\n     */\\n    @PostMapping(value = \\"/queryAnalysisFailedDrmData\\")\\n    public ArchCompassResponse queryAnalysisFailedDrmData(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<PageQueryResult>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public PageQueryResult process() {\\n\\n                PageList pageList = appDrmAnalysisTransactionRepository.queryByReportIdAndReferenceForPage(drmQueryRequest.getReportId(),\\n                        drmQueryRequest.getDataId(), \\"Y\\", \\"\\", AnalysisStatusEnum.FAILED.getCode(), drmQueryRequest.getPageSize(),\\n                        drmQueryRequest.getCurrentPage());\\n\\n                PageQueryResult pageQueryResult = new PageQueryResult();\\n                pageQueryResult.setPageSize(drmQueryRequest.getPageSize());\\n                pageQueryResult.setCurrentPage(drmQueryRequest.getCurrentPage());\\n                if (pageList != null && pageList.size() != 0) {\\n                    pageQueryResult.setTotal(pageList.getPaginator().getItems());\\n                    List<AppDrmAnalysisTransactionMO> appDrmAnalysisTransactionMOList\\n                            = AppDrmAnalysisTransactionConvertor.convertToMOList(\\n                            JSON.parseArray(JSON.toJSONString(pageList), AppDrmAnalysisTransactionDO.class));\\n                    pageQueryResult.setResult(appDrmAnalysisTransactionMOList);\\n\\n                }\\n                return pageQueryResult;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryAnalysisFailedDrmData\\");\\n\\n    }\\n\\n}","oldCode":"@GetMapping(value = \\"/queryInvalidDrmTree\\")\\n    public ArchCompassResponse queryInvalidDrmTree(String reportId, String dataId, String invalidFlag) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<DrmResultInfo>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n                ParamCheckHelper.notBlank(reportId, \\"reportId\\");\\n            }\\n\\n            @Override\\n            public DrmResultInfo process() {\\n\\n                AppDrmAnalysisTransactionMO queryAppDrmAnalysisTransactionMO = new AppDrmAnalysisTransactionMO();\\n                if (\\"FULL\\".equals(invalidFlag)) {\\n                    queryAppDrmAnalysisTransactionMO.setInvalidFlag(\\"Y\\");\\n                    queryAppDrmAnalysisTransactionMO.setInvalidDesc(\\"FULL\\");\\n                } else if (\\"PART\\".equals(invalidFlag)) {\\n                    queryAppDrmAnalysisTransactionMO.setInvalidFlag(\\"Y\\");\\n                    queryAppDrmAnalysisTransactionMO.setInvalidDesc(\\"PART\\");\\n                }\\n                queryAppDrmAnalysisTransactionMO.setReportId(reportId);\\n                queryAppDrmAnalysisTransactionMO.setDataId(dataId);\\n                queryAppDrmAnalysisTransactionMO.setAnalysisStatus(AnalysisStatusEnum.COMPLETED.getCode());\\n\\n                List<AppDrmAnalysisTransactionMO> dbDrmInfo = appDrmAnalysisTransactionRepository.queryByReportIdAndReference(\\n                        queryAppDrmAnalysisTransactionMO);\\n                if (CollectionUtils.isEmpty(dbDrmInfo)) {\\n                    return null;\\n                }\\n\\n                //获取DRM推送值\\n                List<AnalysisBatchCondition> analysisBatchConditionList = analysisBatchConditionRepository.queryByBatchId\\n                        (dbDrmInfo.get(0).getBatchId());\\n                String pushTimeStr = analysisBatchConditionList.get(0).getMaxVersion();\\n                List<AppDrmInfoMO> appDrmPushRecordList = appDrmRecordRepository.queryDrmDataByAppNameAndPushTime(\\n                        dbDrmInfo.get(0).getAppName(), DateUtil.getDateTime(pushTimeStr));\\n\\n                //转换赋值推送值\\n                Map<String, String> paramMap = new HashMap<>();\\n                appDrmPushRecordList.forEach(data -> paramMap.put(data.getDataId(), data.getAttributeValue()));\\n\\n                DrmResultInfo drmResultInfo = new DrmResultInfo();\\n                drmResultInfo.setAppName(dbDrmInfo.get(0).getAppName());\\n                drmResultInfo.setRepoUrl(dbDrmInfo.get(0).getRepoUrl());\\n                drmResultInfo.setCommitId(dbDrmInfo.get(0).getCommitId());\\n\\n                Map<String, List<AppDrmAnalysisTransactionMO>> drmResultMap = dbDrmInfo.stream()\\n                        .collect(Collectors.groupingBy(AppDrmAnalysisTransactionMO::getClassPath));\\n                List<DrmTree> drmTreeList = new ArrayList<>();\\n                for (String key : drmResultMap.keySet()) {\\n                    List<AppDrmAnalysisTransactionMO> subDrmTranList = drmResultMap.get(key);\\n                    DrmTree drmTree = new DrmTree();\\n                    drmTree.setClassPath(key);\\n                    List<DrmAttribute> drmAttributeList = new ArrayList<>();\\n                    for (AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO : subDrmTranList) {\\n\\n                        if (StringUtil.isEmpty(drmTree.getClassName())) {\\n                            drmTree.setClassName(appDrmAnalysisTransactionMO.getClassName());\\n                        }\\n                        if (StringUtil.isEmpty(drmTree.getResourceId())) {\\n                            drmTree.setResourceId(appDrmAnalysisTransactionMO.getResourceId());\\n                        }\\n\\n                        DrmAttribute drmAttribute = new DrmAttribute();\\n                        drmAttribute.setAttributeName(appDrmAnalysisTransactionMO.getAttribute());\\n                        //从map中获取推送值\\n                        drmAttribute.setAttributeValue(paramMap.get(appDrmAnalysisTransactionMO.getDataId()));\\n                        drmAttribute.setCommentFlag(appDrmAnalysisTransactionMO.getCommentFlag());\\n                        drmAttribute.setCommentUrl(appDrmAnalysisTransactionMO.getCommentUrl());\\n                        drmAttribute.setDataId(appDrmAnalysisTransactionMO.getDataId());\\n                        drmAttribute.setLatestPushTime(appDrmAnalysisTransactionMO.getLatestPushTime());\\n                        drmAttribute.setReferenceClassCount(appDrmAnalysisTransactionMO.getReferenceClassCount());\\n                        drmAttribute.setAnalysisStatus(appDrmAnalysisTransactionMO.getAnalysisStatus());\\n                        drmAttribute.setInvalidFlag(appDrmAnalysisTransactionMO.getInvalidFlag());\\n                        drmAttribute.setInvalidDesc(appDrmAnalysisTransactionMO.getInvalidDesc());\\n                        if (!StringUtil.isEmpty(appDrmAnalysisTransactionMO.getMemo())) {\\n                            DrmSummaryInfo drmSummaryInfo = JSON.parseObject(appDrmAnalysisTransactionMO.getMemo(), DrmSummaryInfo.class);\\n                            drmAttribute.setInvalidBranchNum(drmSummaryInfo.getInvalidBranchNum());\\n                            drmAttribute.setInvalidReferenceClassNum(drmSummaryInfo.getInvalidReferenceClassNum());\\n                            drmAttribute.setTotalBranchNum(drmSummaryInfo.getTotalBranchNum());\\n                            drmAttribute.setTotalReferenceClassNum(drmSummaryInfo.getTotalReferenceClassNum());\\n                        }\\n\\n                        drmAttributeList.add(drmAttribute);\\n                    }\\n                    drmTree.setAttributeList(drmAttributeList);\\n                    drmTreeList.add(drmTree);\\n\\n                }\\n                Collections.sort(drmTreeList, new Comparator<DrmTree>() {\\n                    @Override\\n                    public int compare(DrmTree o1, DrmTree o2) {\\n                        return o1.getClassName().compareTo(o2.getClassName());\\n                    }\\n                });\\n                drmResultInfo.setDrmTreeList(drmTreeList);\\n\\n                return drmResultInfo;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmTree\\");\\n\\n    }","oldFullCode":"/*\\n * Ant Group\\n * Copyright (c) 2004-2023 All Rights Reserved.\\n */\\npackage com.alipay.archcompass.web.controller.invalidanalysis;\\n\\nimport com.alibaba.common.lang.StringUtil;\\nimport com.alibaba.fastjson.JSON;\\nimport com.alipay.archcompass.common.dal.transaction.auto.dataobject.AppDrmAnalysisDetailDO;\\nimport com.alipay.archcompass.common.dal.transaction.auto.dataobject.AppDrmAnalysisTransactionDO;\\nimport com.alipay.archcompass.common.dal.transaction.auto.dataobject.AppDrmInfoDO;\\nimport com.alipay.archcompass.common.facade.response.ArchCompassResponse;\\nimport com.alipay.archcompass.common.service.integration.codebase.CodebaseClient;\\nimport com.alipay.archcompass.common.service.integration.codebase.result.CodeContentLineData;\\nimport com.alipay.archcompass.common.service.integration.codeinsight.CodeInsightClient;\\nimport com.alipay.archcompass.common.service.integration.codeinsight.request.CodeInsightRequest;\\nimport com.alipay.archcompass.common.service.integration.codeinsight.request.PatchData;\\nimport com.alipay.archcompass.common.service.integration.drm.DrmConfig;\\nimport com.alipay.archcompass.common.util.DateUtil;\\nimport com.alipay.archcompass.core.model.common.ArchCompassServiceCallBack;\\nimport com.alipay.archcompass.core.model.common.ArchCompassServiceTemplate;\\nimport com.alipay.archcompass.core.model.common.check.ParamCheckHelper;\\nimport com.alipay.archcompass.core.model.constant.RequestConstant;\\nimport com.alipay.archcompass.core.model.domain.AppDrmAnalysisDetailMO;\\nimport com.alipay.archcompass.core.model.domain.AppDrmAnalysisTransactionMO;\\nimport com.alipay.archcompass.core.model.domain.AppDrmClassDetailMO;\\nimport com.alipay.archcompass.core.model.domain.AppDrmInfoMO;\\nimport com.alipay.archcompass.core.model.domain.DrmSummaryInfo;\\nimport com.alipay.archcompass.core.model.domain.analysis.AnalysisBatchCondition;\\nimport com.alipay.archcompass.core.model.domain.drm.DrmAttribute;\\nimport com.alipay.archcompass.core.model.domain.drm.DrmDigestInfo;\\nimport com.alipay.archcompass.core.model.domain.drm.DrmResultInfo;\\nimport com.alipay.archcompass.core.model.domain.drm.DrmTree;\\nimport com.alipay.archcompass.core.model.domain.drm.InValidMethodSummary;\\nimport com.alipay.archcompass.core.model.enums.AnalysisStatusEnum;\\nimport com.alipay.archcompass.core.model.response.PageQueryResult;\\nimport com.alipay.archcompass.core.service.AnalysisBatchConditionRepository;\\nimport com.alipay.archcompass.core.service.AppDrmAnalysisDetailRepository;\\nimport com.alipay.archcompass.core.service.AppDrmAnalysisTransactionRepository;\\nimport com.alipay.archcompass.core.service.AppDrmRecordRepository;\\nimport com.alipay.archcompass.core.service.convertor.AppDrmAnalysisDetailConvertor;\\nimport com.alipay.archcompass.core.service.convertor.AppDrmAnalysisTransactionConvertor;\\nimport com.alipay.archcompass.core.service.convertor.AppDrmInfoConvertor;\\nimport com.alipay.sofa.runtime.api.annotation.SofaReference;\\nimport com.github.difflib.DiffUtils;\\nimport com.github.difflib.UnifiedDiffUtils;\\nimport com.github.difflib.patch.Patch;\\nimport com.iwallet.biz.common.util.PageList;\\nimport org.springframework.context.annotation.Scope;\\nimport org.springframework.util.CollectionUtils;\\nimport org.springframework.web.bind.annotation.GetMapping;\\nimport org.springframework.web.bind.annotation.PostMapping;\\nimport org.springframework.web.bind.annotation.RequestBody;\\nimport org.springframework.web.bind.annotation.RequestMapping;\\nimport org.springframework.web.bind.annotation.RestController;\\n\\nimport java.util.ArrayList;\\nimport java.util.Calendar;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.Date;\\nimport java.util.HashMap;\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.stream.Collectors;\\n\\n/**\\n * @author John\\n * @version DrmQueryController.java, v 0.1 2023年10月11日 11:06 John\\n */\\n@RestController\\n@Scope(value = \\"prototype\\")\\n@RequestMapping(value = RequestConstant.WEB_API)\\npublic class DrmQueryController {\\n\\n    @SofaReference\\n    private AppDrmRecordRepository appDrmRecordRepository;\\n\\n    @SofaReference\\n    private AppDrmAnalysisTransactionRepository appDrmAnalysisTransactionRepository;\\n\\n    @SofaReference\\n    private AppDrmAnalysisDetailRepository appDrmAnalysisDetailRepository;\\n\\n    @SofaReference\\n    private CodebaseClient codebaseClient;\\n\\n    @SofaReference\\n    private CodeInsightClient codeInsightClient;\\n\\n    @SofaReference\\n    private AnalysisBatchConditionRepository analysisBatchConditionRepository;\\n\\n    @SofaReference\\n    private DrmConfig drmConfig;\\n\\n    @PostMapping(value = \\"/queryDrmDataByPushRecord\\")\\n    public ArchCompassResponse queryDrmDataByPushRecord(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<PageQueryResult>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n                ParamCheckHelper.notBlank(drmQueryRequest.getAppName(), \\"appName\\");\\n                ParamCheckHelper.notBlank(drmQueryRequest.getTimeInterval(), \\"timeRange\\");\\n            }\\n\\n            @Override\\n            public PageQueryResult process() {\\n                Date date = null;\\n                if (StringUtil.isEmpty(drmQueryRequest.getActualTime())) {\\n                    int numberOfMonths = Integer.valueOf(drmQueryRequest.getTimeInterval());\\n\\n                    Calendar calendar = Calendar.getInstance();\\n                    calendar.add(Calendar.MONTH, -numberOfMonths);\\n\\n                    date = calendar.getTime();\\n                } else {\\n                    date = DateUtil.getDateTime(drmQueryRequest.getActualTime());\\n                }\\n                PageList pageList = appDrmRecordRepository.queryDrmDataByAppNameAndPushTimeForPage(drmQueryRequest.getAppName(), drmQueryRequest.getDataId(), date,\\n                        drmQueryRequest.getPageSize(), drmQueryRequest.getCurrentPage());\\n\\n                PageQueryResult pageQueryResult = new PageQueryResult();\\n                pageQueryResult.setPageSize(drmQueryRequest.getPageSize());\\n                pageQueryResult.setCurrentPage(drmQueryRequest.getCurrentPage());\\n                if (pageList != null && pageList.size() != 0) {\\n                    pageQueryResult.setTotal(pageList.getPaginator().getItems());\\n                    List<AppDrmInfoMO> appDrmInfoMOList = AppDrmInfoConvertor.convertToMOList(\\n                            JSON.parseArray(JSON.toJSONString(pageList), AppDrmInfoDO.class));\\n                    pageQueryResult.setResult(appDrmInfoMOList);\\n\\n                }\\n                return pageQueryResult;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryDrmDataByPushRecord\\");\\n\\n    }\\n\\n    @GetMapping(value = \\"/queryInvalidDrmTree\\")\\n    public ArchCompassResponse queryInvalidDrmTree(String reportId, String dataId, String invalidFlag) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<DrmResultInfo>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n                ParamCheckHelper.notBlank(reportId, \\"reportId\\");\\n            }\\n\\n            @Override\\n            public DrmResultInfo process() {\\n\\n                AppDrmAnalysisTransactionMO queryAppDrmAnalysisTransactionMO = new AppDrmAnalysisTransactionMO();\\n                if (\\"FULL\\".equals(invalidFlag)) {\\n                    queryAppDrmAnalysisTransactionMO.setInvalidFlag(\\"Y\\");\\n                    queryAppDrmAnalysisTransactionMO.setInvalidDesc(\\"FULL\\");\\n                } else if (\\"PART\\".equals(invalidFlag)) {\\n                    queryAppDrmAnalysisTransactionMO.setInvalidFlag(\\"Y\\");\\n                    queryAppDrmAnalysisTransactionMO.setInvalidDesc(\\"PART\\");\\n                }\\n                queryAppDrmAnalysisTransactionMO.setReportId(reportId);\\n                queryAppDrmAnalysisTransactionMO.setDataId(dataId);\\n                queryAppDrmAnalysisTransactionMO.setAnalysisStatus(AnalysisStatusEnum.COMPLETED.getCode());\\n\\n                List<AppDrmAnalysisTransactionMO> dbDrmInfo = appDrmAnalysisTransactionRepository.queryByReportIdAndReference(\\n                        queryAppDrmAnalysisTransactionMO);\\n                if (CollectionUtils.isEmpty(dbDrmInfo)) {\\n                    return null;\\n                }\\n\\n                //获取DRM推送值\\n                List<AnalysisBatchCondition> analysisBatchConditionList = analysisBatchConditionRepository.queryByBatchId\\n                        (dbDrmInfo.get(0).getBatchId());\\n                String pushTimeStr = analysisBatchConditionList.get(0).getMaxVersion();\\n                List<AppDrmInfoMO> appDrmPushRecordList = appDrmRecordRepository.queryDrmDataByAppNameAndPushTime(\\n                        dbDrmInfo.get(0).getAppName(), DateUtil.getDateTime(pushTimeStr));\\n\\n                //转换赋值推送值\\n                Map<String, String> paramMap = new HashMap<>();\\n                appDrmPushRecordList.forEach(data -> paramMap.put(data.getDataId(), data.getAttributeValue()));\\n\\n                DrmResultInfo drmResultInfo = new DrmResultInfo();\\n                drmResultInfo.setAppName(dbDrmInfo.get(0).getAppName());\\n                drmResultInfo.setRepoUrl(dbDrmInfo.get(0).getRepoUrl());\\n                drmResultInfo.setCommitId(dbDrmInfo.get(0).getCommitId());\\n\\n                Map<String, List<AppDrmAnalysisTransactionMO>> drmResultMap = dbDrmInfo.stream()\\n                        .collect(Collectors.groupingBy(AppDrmAnalysisTransactionMO::getClassPath));\\n                List<DrmTree> drmTreeList = new ArrayList<>();\\n                for (String key : drmResultMap.keySet()) {\\n                    List<AppDrmAnalysisTransactionMO> subDrmTranList = drmResultMap.get(key);\\n                    DrmTree drmTree = new DrmTree();\\n                    drmTree.setClassPath(key);\\n                    List<DrmAttribute> drmAttributeList = new ArrayList<>();\\n                    for (AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO : subDrmTranList) {\\n\\n                        if (StringUtil.isEmpty(drmTree.getClassName())) {\\n                            drmTree.setClassName(appDrmAnalysisTransactionMO.getClassName());\\n                        }\\n                        if (StringUtil.isEmpty(drmTree.getResourceId())) {\\n                            drmTree.setResourceId(appDrmAnalysisTransactionMO.getResourceId());\\n                        }\\n\\n                        DrmAttribute drmAttribute = new DrmAttribute();\\n                        drmAttribute.setAttributeName(appDrmAnalysisTransactionMO.getAttribute());\\n                        //从map中获取推送值\\n                        drmAttribute.setAttributeValue(paramMap.get(appDrmAnalysisTransactionMO.getDataId()));\\n                        drmAttribute.setCommentFlag(appDrmAnalysisTransactionMO.getCommentFlag());\\n                        drmAttribute.setCommentUrl(appDrmAnalysisTransactionMO.getCommentUrl());\\n                        drmAttribute.setDataId(appDrmAnalysisTransactionMO.getDataId());\\n                        drmAttribute.setLatestPushTime(appDrmAnalysisTransactionMO.getLatestPushTime());\\n                        drmAttribute.setReferenceClassCount(appDrmAnalysisTransactionMO.getReferenceClassCount());\\n                        drmAttribute.setAnalysisStatus(appDrmAnalysisTransactionMO.getAnalysisStatus());\\n                        drmAttribute.setInvalidFlag(appDrmAnalysisTransactionMO.getInvalidFlag());\\n                        drmAttribute.setInvalidDesc(appDrmAnalysisTransactionMO.getInvalidDesc());\\n                        if (!StringUtil.isEmpty(appDrmAnalysisTransactionMO.getMemo())) {\\n                            DrmSummaryInfo drmSummaryInfo = JSON.parseObject(appDrmAnalysisTransactionMO.getMemo(), DrmSummaryInfo.class);\\n                            drmAttribute.setInvalidBranchNum(drmSummaryInfo.getInvalidBranchNum());\\n                            drmAttribute.setInvalidReferenceClassNum(drmSummaryInfo.getInvalidReferenceClassNum());\\n                            drmAttribute.setTotalBranchNum(drmSummaryInfo.getTotalBranchNum());\\n                            drmAttribute.setTotalReferenceClassNum(drmSummaryInfo.getTotalReferenceClassNum());\\n                        }\\n\\n                        drmAttributeList.add(drmAttribute);\\n                    }\\n                    drmTree.setAttributeList(drmAttributeList);\\n                    drmTreeList.add(drmTree);\\n\\n                }\\n                Collections.sort(drmTreeList, new Comparator<DrmTree>() {\\n                    @Override\\n                    public int compare(DrmTree o1, DrmTree o2) {\\n                        return o1.getClassName().compareTo(o2.getClassName());\\n                    }\\n                });\\n                drmResultInfo.setDrmTreeList(drmTreeList);\\n\\n                return drmResultInfo;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmTree\\");\\n\\n    }\\n\\n    @GetMapping(value = \\"/queryInvalidDrmAssetAnalysisSummary\\")\\n    public ArchCompassResponse queryInvalidDrmAssetAnalysisSummary(String reportId) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<Map<String, Object>>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n                ParamCheckHelper.notBlank(reportId, \\"reportId\\");\\n            }\\n\\n            @Override\\n            public Map<String, Object> process() {\\n\\n                List<AppDrmAnalysisTransactionMO> drmAnalysisTransactionMOList\\n                        = appDrmAnalysisTransactionRepository.queryByReportId(reportId);\\n                if (CollectionUtils.isEmpty(drmAnalysisTransactionMOList)) {\\n                    return null;\\n                }\\n\\n                int totalCount = drmAnalysisTransactionMOList.size();\\n                int successCount = 0;\\n                int failCount = 0;\\n                int directReferenceCount = 0;\\n                int inDirectReferenceCount = 0;\\n                int invalidDrmCount = 0;\\n                int fullInvalidDrmCount = 0;\\n                int partInvalidDrmCount = 0;\\n                for (AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO : drmAnalysisTransactionMOList) {\\n                    if (AnalysisStatusEnum.COMPLETED.getCode().equals(appDrmAnalysisTransactionMO.getAnalysisStatus())) {\\n                        successCount += 1;\\n                        //成功的数据里获取无效的DRM总数量\\n                        if (\\"Y\\".equals(appDrmAnalysisTransactionMO.getInvalidFlag())) {\\n                            invalidDrmCount += 1;\\n                        }\\n                        if (\\"Y\\".equals(appDrmAnalysisTransactionMO.getInvalidFlag()) && \\"FULL\\".equals(\\n                                appDrmAnalysisTransactionMO.getInvalidDesc())) {\\n                            fullInvalidDrmCount += 1;\\n                        }\\n                        if (\\"Y\\".equals(appDrmAnalysisTransactionMO.getInvalidFlag()) && \\"PART\\".equals(\\n                                appDrmAnalysisTransactionMO.getInvalidDesc())) {\\n                            partInvalidDrmCount += 1;\\n\\n                        }\\n                    }\\n                    if (AnalysisStatusEnum.FAILED.getCode().equals(appDrmAnalysisTransactionMO.getAnalysisStatus())) {\\n                        failCount += 1;\\n                    }\\n                    if (\\"Y\\".equals(appDrmAnalysisTransactionMO.getReferenceFlag())) {\\n                        directReferenceCount += 1;\\n                    }\\n                    if (\\"N\\".equals(appDrmAnalysisTransactionMO.getReferenceFlag())) {\\n                        inDirectReferenceCount += 1;\\n                    }\\n                }\\n\\n                //获取有直接引用的dataId集合\\n                List<String> dataIdList = drmAnalysisTransactionMOList.stream().filter(data -> data.getReferenceFlag().equals(\\"Y\\")).map(\\n                        AppDrmAnalysisTransactionMO::getDataId).collect(\\n                        Collectors.toList());\\n                int relateClassCount = 0;\\n                if (!CollectionUtils.isEmpty(dataIdList)) {\\n                    relateClassCount = appDrmAnalysisDetailRepository.queryByReportIdAndDataIdList(reportId, dataIdList);\\n\\n                }\\n                //List<AnalysisBatchCondition> analysisBatchConditionList = analysisBatchConditionRepository.queryByBatchId\\n                // (drmAnalysisTransactionMOList.get(0).getBatchId());\\n                //String configId = analysisBatchConditionList.get(0).getChangeItemId();\\n\\n                DrmDigestInfo drmDigestInfo = new DrmDigestInfo();\\n\\n                Map<String, String> paramMap = drmConfig.getAppNameConfigIdMap();\\n                if (null == paramMap || paramMap.size() == 0) {\\n                    drmDigestInfo.setCoverageReportUrl(\\"\\");\\n                } else if (null != paramMap.get(drmAnalysisTransactionMOList.get(0).getAppName())) {\\n                    drmDigestInfo.setCoverageReportUrl(\\n                            \\"https://compassprod.alipay.com/config/report/reportDetail?type=OVERALL&configId=\\" + paramMap.get(\\n                                    drmAnalysisTransactionMOList.get(0).getAppName()));\\n                } else {\\n                    drmDigestInfo.setCoverageReportUrl(\\"\\");\\n                }\\n                drmDigestInfo.setFailCount(failCount);\\n                drmDigestInfo.setDirectReferenceCount(directReferenceCount);\\n                drmDigestInfo.setInDirectReferenceCount(inDirectReferenceCount);\\n                drmDigestInfo.setSuccessCount(successCount);\\n                drmDigestInfo.setTotalCount(totalCount);\\n                drmDigestInfo.setCommitId(drmAnalysisTransactionMOList.get(0).getCommitId());\\n                drmDigestInfo.setRelateClassCount(relateClassCount);\\n                drmDigestInfo.setInvalidDrmCount(invalidDrmCount);\\n                drmDigestInfo.setValidDrmCount(successCount - invalidDrmCount);\\n                drmDigestInfo.setFullInvalidDrmCount(fullInvalidDrmCount);\\n                drmDigestInfo.setPartInvalidDrmCount(partInvalidDrmCount);\\n\\n                Map<String, Object> map = new HashMap<>();\\n                map.put(\\"reportId\\", reportId);\\n                map.put(\\"summary\\", drmDigestInfo);\\n                return map;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmAssetAnalysisSummary\\");\\n\\n    }\\n\\n    @PostMapping(value = \\"/queryInvalidDrmClassList\\")\\n    public ArchCompassResponse queryInvalidDrmClassList(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<PageQueryResult>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public PageQueryResult process() {\\n                //先不做报错处理，直接返回null\\n                if (StringUtil.isEmpty(drmQueryRequest.getDataId())) {\\n                    return null;\\n                }\\n\\n                //根据报告ID查询出应用名等信息来\\n                AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO = appDrmAnalysisTransactionRepository.queryByReportIdAndDataId(\\n                        drmQueryRequest.getReportId(), drmQueryRequest.getDataId());\\n\\n                String configId = \\"\\";\\n                Map<String, String> paramMap = drmConfig.getAppNameConfigIdMap();\\n\\n                if (!paramMap.isEmpty() && null != paramMap.get(appDrmAnalysisTransactionMO.getAppName())) {\\n                    configId = paramMap.get(appDrmAnalysisTransactionMO.getAppName());\\n                }\\n\\n                PageList pageList = appDrmAnalysisDetailRepository.queryDataForPage(drmQueryRequest.getReportId(),\\n                        drmQueryRequest.getDataId(), drmQueryRequest.getClassName(), drmQueryRequest.getInvalidFlag(),\\n                        drmQueryRequest.getPageSize(), drmQueryRequest.getCurrentPage());\\n\\n                PageQueryResult pageQueryResult = new PageQueryResult();\\n                pageQueryResult.setPageSize(drmQueryRequest.getPageSize());\\n                pageQueryResult.setCurrentPage(drmQueryRequest.getCurrentPage());\\n                if (pageList != null && pageList.size() != 0) {\\n                    pageQueryResult.setTotal(pageList.getPaginator().getItems());\\n                    List<AppDrmClassDetailMO> appDrmClassDetailMOList = AppDrmAnalysisDetailConvertor.convertToClassMOList(\\n                            JSON.parseArray(JSON.toJSONString(pageList), AppDrmAnalysisDetailDO.class), configId);\\n                    pageQueryResult.setResult(appDrmClassDetailMOList);\\n\\n                }\\n                return pageQueryResult;\\n\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmClassList\\");\\n\\n    }\\n\\n    @PostMapping(value = \\"/queryInvalidDrmClassContent\\")\\n    public ArchCompassResponse queryInvalidDrmClassContent(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<List<CodeContentLineData>>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public List<CodeContentLineData> process() {\\n\\n                AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO = appDrmAnalysisTransactionRepository.queryByReportIdAndDataId(\\n                        drmQueryRequest.getReportId(), drmQueryRequest.getDataId());\\n\\n                List<CodeContentLineData> codeContentLineDataList = codebaseClient.queryCodeFileContent(\\n                        appDrmAnalysisTransactionMO.getRepoUrl(), \\"\\", appDrmAnalysisTransactionMO.getCommitId(),\\n                        drmQueryRequest.getFilePath());\\n\\n                if (CollectionUtils.isEmpty(codeContentLineDataList)) {\\n                    return null;\\n                }\\n\\n                AppDrmAnalysisDetailMO appDrmAnalysisDetailMO = appDrmAnalysisDetailRepository.queryByReportIdAndDataIdAndFilePath(\\n                        drmQueryRequest.getReportId(), drmQueryRequest.getDataId(), drmQueryRequest.getFilePath());\\n                List<InValidMethodSummary> inValidMethodSummaryList = JSON.parseArray(appDrmAnalysisDetailMO.getRefFileDetail(),\\n                        InValidMethodSummary.class);\\n\\n                //从里面取出存在无效标记的数据\\n                List<Integer> coverCodeLineList = new ArrayList<>();\\n                List<Integer> unCoverCodeLineList = new ArrayList<>();\\n\\n                //覆盖行 标记绿色 未覆盖行 标记红色\\n                for (InValidMethodSummary inValidMethodSummary : inValidMethodSummaryList) {\\n                    if (\\"Y\\".equals(inValidMethodSummary.getInValidFlag())) {\\n                        if (!CollectionUtils.isEmpty(inValidMethodSummary.getCoverCodeLineList())) {\\n                            coverCodeLineList.addAll(inValidMethodSummary.getCoverCodeLineList());\\n                        }\\n                        if (!CollectionUtils.isEmpty(inValidMethodSummary.getUnCoverCodeLineList())) {\\n                            unCoverCodeLineList.addAll(inValidMethodSummary.getUnCoverCodeLineList());\\n                        }\\n                    }\\n                }\\n                for (CodeContentLineData codeContentLineData : codeContentLineDataList) {\\n                    codeContentLineData.setLineNumber(codeContentLineData.getLineNumber() + 1);\\n                    //进行染色\\n                    if (unCoverCodeLineList.contains(codeContentLineData.getLineNumber())) {\\n                        codeContentLineData.setLineColor(\\"RED\\");\\n                    }\\n\\n                }\\n                return codeContentLineDataList;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryInvalidDrmClassContent\\");\\n\\n    }\\n\\n    @PostMapping(value = \\"/createCodeComments\\")\\n    public ArchCompassResponse createCodeComments(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<String>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public String process() {\\n\\n                AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO = appDrmAnalysisTransactionRepository.queryByReportIdAndDataId(\\n                        drmQueryRequest.getReportId(), drmQueryRequest.getDataId());\\n\\n                List<PatchData> patchDataList = new ArrayList<>();\\n\\n                CodeInsightRequest codeInsightRequest = new CodeInsightRequest();\\n                codeInsightRequest.setBranch(\\"master\\");\\n                codeInsightRequest.setCommit(appDrmAnalysisTransactionMO.getCommitId());\\n                codeInsightRequest.setCommitMsg(\\"自动标注无效代码块\\");\\n                codeInsightRequest.setRepoUrl(appDrmAnalysisTransactionMO.getRepoUrl());\\n\\n                String commentUrl = \\"\\";\\n                if (StringUtil.isEmpty(drmQueryRequest.getFilePath())) {\\n                    List<AppDrmAnalysisDetailMO> appDrmAnalysisDetailMOList = appDrmAnalysisDetailRepository.queryByReportIdAndDataId(\\n                            drmQueryRequest.getReportId(), drmQueryRequest.getDataId(), \\"Y\\");\\n                    for (AppDrmAnalysisDetailMO appDrmAnalysisDetailMO : appDrmAnalysisDetailMOList) {\\n                        PatchData patchData = handleCommentUrl(appDrmAnalysisTransactionMO, appDrmAnalysisDetailMO.getRefFilePath(),\\n                                appDrmAnalysisDetailMO.getRefFileDetail());\\n                        if (null != patchData) {\\n                            patchDataList.add(patchData);\\n                        }\\n                    }\\n                    codeInsightRequest.setPatches(patchDataList);\\n\\n                    commentUrl = codeInsightClient.createCodeComments(codeInsightRequest);\\n\\n                    appDrmAnalysisTransactionMO.setCommentUrl(commentUrl);\\n                    appDrmAnalysisTransactionMO.setCommentFlag(\\"Y\\");\\n                    appDrmAnalysisTransactionRepository.updateCommentInfoByReportIdAndDataId(appDrmAnalysisTransactionMO);\\n\\n                    //更新标注记录\\n                    AppDrmAnalysisDetailMO updateAppDrmAnalysisDetailMO = new AppDrmAnalysisDetailMO();\\n                    updateAppDrmAnalysisDetailMO.setReportId(drmQueryRequest.getReportId());\\n                    updateAppDrmAnalysisDetailMO.setDataId(drmQueryRequest.getDataId());\\n                    updateAppDrmAnalysisDetailMO.setCommentUrl(commentUrl);\\n                    updateAppDrmAnalysisDetailMO.setCommentFlag(\\"Y\\");\\n                    appDrmAnalysisDetailRepository.updateByReportIdAndDataIdAndFilePath(updateAppDrmAnalysisDetailMO);\\n\\n                } else {\\n                    AppDrmAnalysisDetailMO appDrmAnalysisDetailMO = appDrmAnalysisDetailRepository.queryByReportIdAndDataIdAndFilePath(\\n                            drmQueryRequest.getReportId(), drmQueryRequest.getDataId(), drmQueryRequest.getFilePath());\\n                    PatchData patchData = handleCommentUrl(appDrmAnalysisTransactionMO, appDrmAnalysisDetailMO.getRefFilePath(),\\n                            appDrmAnalysisDetailMO.getRefFileDetail());\\n                    if (null != patchData) {\\n                        patchDataList.add(patchData);\\n                    }\\n                    codeInsightRequest.setPatches(patchDataList);\\n\\n                    commentUrl = codeInsightClient.createCodeComments(codeInsightRequest);\\n                    //更新标注记录\\n                    appDrmAnalysisDetailMO.setCommentUrl(commentUrl);\\n                    appDrmAnalysisDetailMO.setCommentFlag(\\"Y\\");\\n                    appDrmAnalysisDetailRepository.updateByReportIdAndDataIdAndFilePath(appDrmAnalysisDetailMO);\\n\\n                    //有且仅有一个的话，直接把流水表也标注了\\n                    if (!StringUtil.isEmpty(appDrmAnalysisTransactionMO.getMemo())) {\\n                        DrmSummaryInfo drmSummaryInfo = JSON.parseObject(appDrmAnalysisTransactionMO.getMemo(), DrmSummaryInfo.class);\\n                        if (1 == drmSummaryInfo.getInvalidReferenceClassNum()) {\\n                            appDrmAnalysisTransactionMO.setCommentUrl(commentUrl);\\n                            appDrmAnalysisTransactionMO.setCommentFlag(\\"Y\\");\\n                            appDrmAnalysisTransactionRepository.updateCommentInfoByReportIdAndDataId(appDrmAnalysisTransactionMO);\\n\\n                        }\\n\\n                    }\\n                }\\n\\n                return commentUrl;\\n            }\\n\\n            private PatchData handleCommentUrl(AppDrmAnalysisTransactionMO appDrmAnalysisTransactionMO, String filePath,\\n                                               String fileDetail) {\\n                List<CodeContentLineData> codeContentLineDataList = codebaseClient.queryCodeFileContent(\\n                        appDrmAnalysisTransactionMO.getRepoUrl(), \\"master\\", appDrmAnalysisTransactionMO.getCommitId(), filePath);\\n\\n                List<String> sourceFileContentList = new ArrayList<>();\\n                List<String> targetFileContentList = new ArrayList<>();\\n\\n                List<InValidMethodSummary> methodSummaryList = JSON.parseArray(fileDetail, InValidMethodSummary.class);\\n                List<Integer> inValidMethodLineList = new ArrayList<>();\\n                for (InValidMethodSummary inValidMethodSummary : methodSummaryList) {\\n                    if (\\"Y\\".equals(inValidMethodSummary.getInValidFlag()) && !CollectionUtils.isEmpty(\\n                            inValidMethodSummary.getUnCoverCodeLineList())) {\\n                        inValidMethodLineList.addAll(inValidMethodSummary.getUnCoverCodeLineList());\\n                    }\\n                }\\n                if (CollectionUtils.isEmpty(inValidMethodLineList)) {\\n                    return null;\\n                }\\n                //Map<Integer, List<Integer>> resultMap = splitLineMapData(inValidMethodLineList);\\n\\n                for (CodeContentLineData codeContentLineData : codeContentLineDataList) {\\n                    codeContentLineData.setLineNumber(codeContentLineData.getLineNumber() + 1);\\n                    sourceFileContentList.add(codeContentLineData.getLineContent());\\n                    //if (inValidMethodLineList.contains(codeContentLineData.getLineNumber())) {\\n                    //    continue;\\n                    //}\\n                    //targetFileContentList.add(codeContentLineData.getLineContent());\\n                    //匹配到行号数据后\\n                    if (inValidMethodLineList.contains(codeContentLineData.getLineNumber())) {\\n                        String content = codeContentLineData.getLineContent()\\n                                + \\"//the current code line is not covered by production traffic\\";\\n                        targetFileContentList.add(content);\\n\\n                        //List<Integer> lineNumberList = resultMap.get(codeContentLineData.getLineNumber());\\n                        //if (!CollectionUtils.isEmpty(lineNumberList)) {\\n                        //    String content;\\n                        //    if (lineNumberList.size() == 1) {\\n                        //        content = codeContentLineData.getLineContent()\\n                        //                + \\" //The current code line is not covered by production traffic\\";\\n                        //    } else {\\n                        //        content = codeContentLineData.getLineContent()\\n                        //                + \\" //The code from lines \\" + lineNumberList.get(0) + \\" to \\" + lineNumberList.get(\\n                        //                lineNumberList.size() - 1) + \\" is not covered by production traffic\\";\\n                        //    }\\n                        //\\n                        //    targetFileContentList.add(content);\\n                    } else {\\n                        targetFileContentList.add(codeContentLineData.getLineContent());\\n                    }\\n                }\\n                if (CollectionUtils.isEmpty(sourceFileContentList) || CollectionUtils.isEmpty(targetFileContentList)) {\\n                    return null;\\n                }\\n\\n                Patch<String> patch = DiffUtils.diff(sourceFileContentList, targetFileContentList);\\n\\n                List<String> unifiedDiff = UnifiedDiffUtils.generateUnifiedDiff(\\"\\", \\"\\", sourceFileContentList, patch, 1);\\n\\n                String rawPatch = String.join(\\"\\\\n\\", unifiedDiff.subList(2, unifiedDiff.size()));\\n                String rawPatchStr = String.format(\\"--- \\\\n+++ \\\\n%s\\", rawPatch);\\n\\n                PatchData patchData = new PatchData();\\n                patchData.setPatch(rawPatchStr);\\n                patchData.setPath(filePath);\\n                return patchData;\\n\\n            }\\n\\n            //private Map<Integer, List<Integer>> splitLineMapData(List<Integer> inValidMethodLineList) {\\n            //\\n            //    Map<Integer, List<Integer>> groupedMap = new LinkedHashMap<>();\\n            //    int currentGroupStart = inValidMethodLineList.get(0);\\n            //    List<Integer> currentGroup = new ArrayList<>();\\n            //    currentGroup.add(currentGroupStart);\\n            //\\n            //    for (int i = 1; i < inValidMethodLineList.size(); i++) {\\n            //        int currentNumber = inValidMethodLineList.get(i);\\n            //        int previousNumber = inValidMethodLineList.get(i - 1);\\n            //\\n            //        if (currentNumber - previousNumber == 1) {\\n            //            currentGroup.add(currentNumber);\\n            //        } else {\\n            //            groupedMap.put(currentGroupStart, currentGroup);\\n            //            currentGroupStart = currentNumber;\\n            //            currentGroup = new ArrayList<>();\\n            //            currentGroup.add(currentGroupStart);\\n            //        }\\n            //    }\\n            //\\n            //    groupedMap.put(currentGroupStart, currentGroup);\\n            //    return groupedMap;\\n            //\\n            //}\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"createCodeComments\\");\\n\\n    }\\n\\n    @PostMapping(value = \\"/queryUnDirectReferenceDrmData\\")\\n    public ArchCompassResponse queryUnDirectReferenceDrmData(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<PageQueryResult>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public PageQueryResult process() {\\n\\n                PageList pageList = appDrmAnalysisTransactionRepository.queryByReportIdAndReferenceForPage(drmQueryRequest.getReportId(),\\n                        drmQueryRequest.getDataId(), \\"N\\", \\"\\", \\"\\", drmQueryRequest.getPageSize(), drmQueryRequest.getCurrentPage());\\n\\n                PageQueryResult pageQueryResult = new PageQueryResult();\\n                pageQueryResult.setPageSize(drmQueryRequest.getPageSize());\\n                pageQueryResult.setCurrentPage(drmQueryRequest.getCurrentPage());\\n                if (pageList != null && pageList.size() != 0) {\\n                    pageQueryResult.setTotal(pageList.getPaginator().getItems());\\n                    List<AppDrmAnalysisTransactionMO> appDrmAnalysisTransactionMOList\\n                            = AppDrmAnalysisTransactionConvertor.convertToMOList(\\n                            JSON.parseArray(JSON.toJSONString(pageList), AppDrmAnalysisTransactionDO.class));\\n                    pageQueryResult.setResult(appDrmAnalysisTransactionMOList);\\n\\n                }\\n                return pageQueryResult;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryUnDirectReferenceDrmData\\");\\n\\n    }\\n\\n    /**\\n     * 查询分析失败的DRM数据\\n     *\\n     * @param drmQueryRequest\\n     * @return\\n     */\\n    @PostMapping(value = \\"/queryAnalysisFailedDrmData\\")\\n    public ArchCompassResponse queryAnalysisFailedDrmData(@RequestBody DrmQueryRequest drmQueryRequest) {\\n        return ArchCompassServiceTemplate.execute(new ArchCompassServiceCallBack<PageQueryResult>() {\\n\\n            @Override\\n            public void beforeProcess() {\\n            }\\n\\n            @Override\\n            public PageQueryResult process() {\\n\\n                PageList pageList = appDrmAnalysisTransactionRepository.queryByReportIdAndReferenceForPage(drmQueryRequest.getReportId(),\\n                        drmQueryRequest.getDataId(), \\"Y\\", \\"\\", AnalysisStatusEnum.FAILED.getCode(), drmQueryRequest.getPageSize(),\\n                        drmQueryRequest.getCurrentPage());\\n\\n                PageQueryResult pageQueryResult = new PageQueryResult();\\n                pageQueryResult.setPageSize(drmQueryRequest.getPageSize());\\n                pageQueryResult.setCurrentPage(drmQueryRequest.getCurrentPage());\\n                if (pageList != null && pageList.size() != 0) {\\n                    pageQueryResult.setTotal(pageList.getPaginator().getItems());\\n                    List<AppDrmAnalysisTransactionMO> appDrmAnalysisTransactionMOList\\n                            = AppDrmAnalysisTransactionConvertor.convertToMOList(\\n                            JSON.parseArray(JSON.toJSONString(pageList), AppDrmAnalysisTransactionDO.class));\\n                    pageQueryResult.setResult(appDrmAnalysisTransactionMOList);\\n\\n                }\\n                return pageQueryResult;\\n            }\\n\\n            @Override\\n            public void afterProcess() {\\n\\n            }\\n        }, \\"queryAnalysisFailedDrmData\\");\\n\\n    }\\n\\n}","type":"M"},{"fileName":"DrmAnalysisQueryServiceImpl.java","filePath":"app/biz/compass/src/main/java/com/alipay/archcompass/biz/compass/drm/DrmAnalysisQueryServiceImpl.java","newCode":"@Override\\n    public List<AppDrmMO> queryAllDrmByApp(String appName, String dataIdKeyWord) {\\n        // 01. 校验\\n        if (checkIllegalParam(appName)) {\\n            return Lists.newArrayList();\\n        }\\n\\n        // 02. 查询应用DRM数据\\n        List<AppDrmMO> appDrmMOList = appDrmRepository.queryByAppNameList(Lists.newArrayList(appName), dataIdKeyWord);\\n        if (CollectionUtils.isEmpty(appDrmMOList)) {\\n            return Lists.newArrayList();\\n        }\\n        return appDrmMOList;\\n    }\\n","newFullCode":"/*\\n * Ant Group\\n * Copyright (c) 2004-2022 All Rights Reserved.\\n */\\npackage com.alipay.archcompass.biz.compass.drm;\\n\\nimport com.alibaba.fastjson.JSON;\\nimport com.alipay.archcompass.biz.compass.analysis.BaseAnalysisService;\\nimport com.alipay.archcompass.biz.compass.assets.DrmAnalysisService;\\nimport com.alipay.archcompass.common.util.ArchCompassLogger;\\nimport com.alipay.archcompass.common.util.CollectionUtil;\\nimport com.alipay.archcompass.common.util.DrmUtil;\\nimport com.alipay.archcompass.common.util.LoggerUtil;\\nimport com.alipay.archcompass.core.model.domain.AppDrmMO;\\nimport com.alipay.archcompass.core.model.domain.AppDrmZoneValue;\\nimport com.alipay.archcompass.core.model.domain.AppInfoMO;\\nimport com.alipay.archcompass.core.model.domain.analysis.AnalysisBatch;\\nimport com.alipay.archcompass.core.model.domain.analysis.AnalysisRecord;\\nimport com.alipay.archcompass.core.model.domain.analysis.drm.DrmResourceAttribute;\\nimport com.alipay.archcompass.core.model.domain.analysis.drm.DrmValuesCmpResultBtwApp;\\nimport com.alipay.archcompass.core.model.domain.analysis.drm.DrmValuesCompareResultInApp;\\nimport com.alipay.archcompass.core.model.domain.drm.*;\\nimport com.alipay.archcompass.core.model.enums.*;\\nimport com.alipay.archcompass.core.model.response.PageQueryResult;\\nimport com.alipay.archcompass.core.service.cache.CommonCacheCallback;\\nimport com.alipay.archcompass.core.service.convertor.AppDrmConvertor;\\nimport com.alipay.sofa.runtime.api.annotation.SofaReference;\\nimport com.alipay.sofa.runtime.api.annotation.SofaService;\\nimport com.google.common.collect.Lists;\\nimport com.google.common.collect.Maps;\\nimport org.apache.commons.collections4.ListUtils;\\nimport org.springframework.util.CollectionUtils;\\nimport org.springframework.util.StringUtils;\\n\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.stream.Collectors;\\n\\n/**\\n * @author bue\\n * @version DrmValuesQueryServiceImpl.java, v 0.1 2022年12月02日 10:12 bue\\n */\\n@SofaService\\npublic class DrmAnalysisQueryServiceImpl extends BaseAnalysisService implements DrmAnalysisQueryService {\\n    @SofaReference\\n    private DrmAnalysisService drmAnalysisService;\\n\\n    /**\\n     * 选范围--查询应用下所有的DRM\\n     *\\n     * @param appName 应用名\\n     * @return List\\n     */\\n    @Override\\n    public List<DrmResourceAttribute> queryAppAllDrm(String appName) {\\n        // 01. 入参验证\\n        if (StringUtils.isEmpty(appName)) {\\n            return Lists.newArrayList();\\n        }\\n\\n        // 02. 查询DRM元数据\\n        List<AppDrmMO> appDrmMOList = appDrmRepository.queryByCondition(Lists.newArrayList(appName), null, null);\\n        if (CollectionUtils.isEmpty(appDrmMOList)) {\\n            return Lists.newArrayList();\\n        }\\n\\n        // 03. 生成DRM资源返回值\\n        return AppDrmConvertor.convertToDrmResourceAttributeList(appDrmMOList);\\n    }\\n\\n    /**\\n     * 分析中--查询应用DRM元数据和推送值\\n     *\\n     * @param batchId      分析批次\\n     * @param appName      应用名\\n     * @param appDrmMOList 返回值 元数据\\n     * @param drmValueList 返回值 推送值\\n     * @return Boolean\\n     */\\n    @Override\\n    public boolean queryDrmData(String batchId, String appName, List<AppDrmMO> appDrmMOList, List<DrmValue> drmValueList) {\\n        if (StringUtils.isEmpty(appName)) {\\n            return false;\\n        }\\n        // 查询应用DRM元数据\\n        List<AppDrmMO> appDrmMOs = appDrmRepository.queryByCondition(Lists.newArrayList(appName), null, null);\\n        if (CollectionUtil.isEmpty(appDrmMOs)) {\\n            return true;\\n        }\\n        appDrmMOList.addAll(appDrmMOs);\\n\\n        // 查询应用DRM推送值\\n        List<DrmValue> drmValues = queryAppDrmValuesFromCache(batchId, appName, appDrmMOList, true);\\n        if (CollectionUtil.isEmpty(drmValues)) {\\n            return true;\\n        }\\n        drmValueList.addAll(drmValues);\\n        return true;\\n    }\\n\\n    /**\\n     * 看分析--查询DRM对比分析状态\\n     *\\n     * @param batchId 批次\\n     * @return AnalysisStatusEnum\\n     */\\n    @Override\\n    public AnalysisStatusEnum queryDrmCompareAnalysisStatus(String batchId) {\\n        AnalysisBatch analysisBatch = analysisBatchRepository.queryByBatchId(batchId);\\n        if (analysisBatch == null || !analysisBatch.getBatchStatus().equals(AnalysisBatchStatusEnum.COMPLETED)) {\\n            // 无分析记录, 返回待分析\\n            return AnalysisStatusEnum.PROCESSING;\\n        }\\n        List<AnalysisRecord> analysisRecordList = analysisRecordRepository.queryByBatchId(batchId);\\n        if (CollectionUtils.isEmpty(analysisRecordList)) {\\n            // 有分析记录, 返回待分析\\n            return AnalysisStatusEnum.PROCESSING;\\n        }\\n        for (AnalysisRecord analysisRecord : analysisRecordList) {\\n            switch (analysisRecord.getStatus()) {\\n                case FAILED:\\n                    return AnalysisStatusEnum.FAILED;\\n                case PROCESSING:\\n                    return AnalysisStatusEnum.PROCESSING;\\n                case INIT:\\n                    return AnalysisStatusEnum.INIT;\\n                case RETRY:\\n                    return AnalysisStatusEnum.RETRY;\\n                default:\\n                    break;\\n            }\\n        }\\n        return AnalysisStatusEnum.COMPLETED;\\n    }\\n\\n    /**\\n     * 看分析--应用内--对比概览（分页）\\n     *\\n     * @param batchId          批次号\\n     * @param appName          应用名\\n     * @param currentPage      当前页\\n     * @param pageSize         页大小\\n     * @param resultFilterList 分析结果筛选列表\\n     * @return DrmValuesCompareSummaryInApp\\n     */\\n    @Override\\n    public DrmValuesCompareSummaryInApp queryDrmCompareSummaryPageInApp(String batchId, String appName, int currentPage, int pageSize, String keywordAttribute, List<String> resultFilterList) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageInApp 开始查询应用内对比概览 batchId={0}, appName={1}, currentPage={2}, pageSize={3}\\", batchId, appName, currentPage, pageSize);\\n\\n        DrmValuesCompareSummaryInApp drmValuesCompareSummaryInApp = new DrmValuesCompareSummaryInApp(0, currentPage, pageSize, batchId, appName, Lists.newArrayList());\\n        try {\\n\\n            // 02. 获取应用内对比数据\\n            List<DrmValuesCompareResultInApp> appDrmValuesCompareInApp = queryInDrmCompareResultSummary(batchId, appName, keywordAttribute, resultFilterList);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageInApp 获取应用内对比数据 appDrmValuesCompareInApp={0}\\", JSON.toJSON(appDrmValuesCompareInApp));\\n            if (CollectionUtils.isEmpty(appDrmValuesCompareInApp)) {\\n                // 没查到存在DRM分析结果, 默认返回全空数据\\n                return drmValuesCompareSummaryInApp;\\n            }\\n\\n            // 03. 分页 && 聚合数据\\n            List<DrmValuesCompareSummaryUnitInApp> summary = Lists.newArrayList();\\n            int pageCount = 0;\\n            if (!CollectionUtils.isEmpty(appDrmValuesCompareInApp)) {\\n                // 分页\\n                List<List<DrmValuesCompareResultInApp>> pageList = ListUtils.partition(appDrmValuesCompareInApp, pageSize);\\n                PageQueryResult<List<DrmValuesCompareResultInApp>> pageQueryResult = new PageQueryResult<>();\\n                pageQueryResult.setResult(pageList.get(currentPage - 1));\\n                pageQueryResult.setCurrentPage(currentPage);\\n                pageQueryResult.setPageSize(pageSize);\\n                pageQueryResult.setTotal(appDrmValuesCompareInApp.size());\\n\\n                pageCount = pageQueryResult.getTotal();\\n                summary = AppDrmConvertor.convertToDrmValuesCompareUnitInApp(pageQueryResult.getResult());\\n            }\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageInApp 分页 && 聚合数据 summary={0}\\", JSON.toJSON(summary));\\n\\n            // 04. 组装返回值\\n            drmValuesCompareSummaryInApp.setAppName(appName);\\n            drmValuesCompareSummaryInApp.setBatchId(batchId);\\n            drmValuesCompareSummaryInApp.setPageCount(pageCount);\\n            drmValuesCompareSummaryInApp.setPageSize(pageSize);\\n            drmValuesCompareSummaryInApp.setCurrentPage(currentPage);\\n            drmValuesCompareSummaryInApp.setSummary(summary);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageInApp 组装返回值 drmValuesCompareSummaryInApp={0}\\", JSON.toJSON(drmValuesCompareSummaryInApp));\\n\\n            return drmValuesCompareSummaryInApp;\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"queryDrmCompareSummaryPageInApp 查询异常, batchId={0}, appName={1}\\", batchId, appName);\\n        }\\n        return drmValuesCompareSummaryInApp;\\n    }\\n\\n    /**\\n     * 看分析--应用内--对比详情\\n     *\\n     * @param batchId    批次号\\n     * @param appName    应用名\\n     * @param resourceId 资源\\n     * @param attribute  属性\\n     * @param version    版本\\n     * @return Map<EnvTypeEnum, DrmValuesCompareDetailInApp>\\n     */\\n    @Override\\n    public Map<EnvTypeEnum, DrmValuesCompareDetailInApp> queryDrmCompareDetailInApp(String batchId, String appName, String resourceId, String attribute, String version) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareDetailInApp 开始查询应用内对比详情 batchId={0}, appName={1}, resourceId={2}, attribute={3}, version={4}\\", batchId, appName, resourceId, attribute, version);\\n\\n        Map<EnvTypeEnum, DrmValuesCompareDetailInApp> result = Maps.newHashMap();\\n        try {\\n            result = queryInDrmCompareResultDetail(batchId, appName, resourceId, attribute, version);\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"queryDrmCompareDetailInApp 查询异常, batchId={0}, appName={1}\\", batchId, appName);\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 看分析--应用间--对比概览（分页）\\n     *\\n     * @param batchId                批次号\\n     * @param baseAppName            基线应用名\\n     * @param targetAppName          目标应用名\\n     * @param currentPage            当前页\\n     * @param pageSize               页大小\\n     * @param keywordAttribute       基线属性关键词\\n     * @param keywordTargetAttribute 目标属性关键词\\n     * @param preResultFilterList    预发分析结果过滤条件\\n     * @param grayResultFilterList   灰度分析结果过滤条件\\n     * @param prodResultFilterList   生产分析结果过滤条件\\n     * @return DrmValuesCompareSummaryBetweenApp\\n     */\\n    @Override\\n    public DrmValuesCompareSummaryBetweenApp queryDrmCompareSummaryPageBetweenApp(String batchId, String baseAppName, String targetAppName, int currentPage, int pageSize, String keywordAttribute, String keywordTargetAttribute, List<String> preResultFilterList, List<String> grayResultFilterList, List<String> prodResultFilterList) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageBetweenApp 开始查询应用间对比概览 batchId={0}, baseAppName={1}, targetAppName={2}, currentPage={3}, pageSize={4}\\", batchId, baseAppName, targetAppName, currentPage, pageSize);\\n\\n        DrmValuesCompareSummaryBetweenApp result = new DrmValuesCompareSummaryBetweenApp(0, currentPage, pageSize, batchId, baseAppName, targetAppName, Lists.newArrayList());\\n        try {\\n            // 02. 获取应用间对比数据\\n            List<DrmValuesCmpResultBtwApp> appDrmValuesCompareBetweenApp = queryBtwDrmCompareResultSummary(batchId, baseAppName, targetAppName, keywordAttribute, keywordTargetAttribute, preResultFilterList, grayResultFilterList, prodResultFilterList);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageBetweenApp 获取应用间对比数据 appDrmValuesCompareBetweenApp={0}\\", JSON.toJSON(appDrmValuesCompareBetweenApp));\\n\\n            // 03. 分页 && 聚合数据\\n            List<DrmValuesCompareSummaryUnitBetweenApp> summary = Lists.newArrayList();\\n            int pageCount = 0;\\n            if (!CollectionUtils.isEmpty(appDrmValuesCompareBetweenApp)) {\\n                appDrmValuesCompareBetweenApp.sort((o1, o2) -> {\\n                    int drmCount1 = 0;\\n                    int drmCount2 = 0;\\n                    if (!StringUtils.isEmpty(o1.getAttribute())) {\\n                        drmCount1++;\\n                    }\\n                    if (!StringUtils.isEmpty(o1.getTargetAttribute())) {\\n                        drmCount1++;\\n                    }\\n                    if (!StringUtils.isEmpty(o2.getAttribute())) {\\n                        drmCount2++;\\n                    }\\n                    if (!StringUtils.isEmpty(o2.getTargetAttribute())) {\\n                        drmCount2++;\\n                    }\\n                    if (drmCount1 > drmCount2) {\\n                        return -1;\\n                    } else if (drmCount1 < drmCount2) {\\n                        return 1;\\n                    } else if (drmCount1 == 2) {\\n                        return o1.getAttribute().compareToIgnoreCase(o2.getAttribute());\\n                    } else if (drmCount1 == 1) {\\n                        if (StringUtils.isEmpty(o1.getAttribute()) && !StringUtils.isEmpty(o2.getAttribute())) {\\n                            return 1;\\n                        } else if (!StringUtils.isEmpty(o1.getAttribute()) && StringUtils.isEmpty(o2.getAttribute())) {\\n                            return -1;\\n                        } else if (!StringUtils.isEmpty(o1.getAttribute()) && !StringUtils.isEmpty(o2.getAttribute())) {\\n                            return o1.getAttribute().compareToIgnoreCase(o2.getAttribute());\\n                        } else {\\n                            return o1.getTargetAttribute().compareToIgnoreCase(o2.getTargetAttribute());\\n                        }\\n                    } else {\\n                        return 0;\\n                    }\\n                });\\n                List<List<DrmValuesCmpResultBtwApp>> pageList = ListUtils.partition(appDrmValuesCompareBetweenApp, pageSize);\\n                PageQueryResult<List<DrmValuesCmpResultBtwApp>> pageQueryResult = new PageQueryResult<>();\\n                pageQueryResult.setResult(pageList.get(currentPage - 1));\\n                pageQueryResult.setCurrentPage(currentPage);\\n                pageQueryResult.setPageSize(pageSize);\\n                pageQueryResult.setTotal(appDrmValuesCompareBetweenApp.size());\\n\\n                pageCount = pageQueryResult.getTotal();\\n                summary = AppDrmConvertor.convertToDrmValuesCompareUnitBetweenApp(pageQueryResult.getResult());\\n            }\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageBetweenApp 分页 && 聚合数据 summary={0}\\", JSON.toJSON(summary));\\n\\n\\n            // 04. 组装返回值\\n            result.setBaseAppName(targetAppName);\\n            result.setBatchId(batchId);\\n            result.setPageCount(pageCount);\\n            result.setPageSize(pageSize);\\n            result.setCurrentPage(currentPage);\\n            result.setSummary(summary);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageBetweenApp 组装返回值 result={0}\\", JSON.toJSON(result));\\n\\n            return result;\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"queryDrmCompareSummaryPageBetweenApp 查询异常, batchId={0}, baseAppName={1}, targetAppName={2}\\", batchId, baseAppName, targetAppName);\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 看分析--应用间--对比详情\\n     *\\n     * @param batchId       批次号\\n     * @param baseAppName   基线应用\\n     * @param targetAppName 目标应用\\n     * @return DrmValuesCompareDetailBetweenApp\\n     */\\n    @Override\\n    public Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp> queryDrmCompareDetailBetweenApp(String batchId, String baseAppName, String targetAppName, String baseResourceId, String targetResourceId, String baseAttribute, String targetAttribute, String baseVersion, String targetVersion) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareDetailBetweenApp 开始查询应用内对比详情 batchId={0}, baseAppName={1}, targetAppName={2}, baseResourceId={3}, targetResourceId={4}, baseAttribute={5}, targetAttribute={6}, baseVersion={7}, targetVersion={8}\\", batchId, baseAppName, targetAppName, baseResourceId, targetResourceId, baseAttribute, targetAttribute, baseVersion, targetVersion);\\n\\n        Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp> result = Maps.newHashMap();\\n        try {\\n            result = queryBtwDrmCompareResultDetail(batchId, baseAppName, targetAppName, baseResourceId, targetResourceId, baseAttribute, targetAttribute, baseVersion, targetVersion);\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"queryDrmCompareDetailBetweenApp 查询异常, batchId={0}, baseAppName={1}, targetAppName={2}\\", batchId, baseAppName, targetAppName);\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 获取应用间对比概览数据\\n     *\\n     * @param batchId                批次\\n     * @param baseAppName            基线应用\\n     * @param targetAppName          目标应用\\n     * @param keywordAttribute       基线attribute关键词\\n     * @param keywordTargetAttribute 目标attribute关键词\\n     * @param preResultFilterList    预发分析结果过滤条件\\n     * @param grayResultFilterList   灰度分析结果过滤条件\\n     * @param prodResultFilterList   生产分析结果过滤条件\\n     * @return List<AppDrmValuesCompareResultBetweenApp>\\n     */\\n    private List<DrmValuesCmpResultBtwApp> queryBtwDrmCompareResultSummary(String batchId, String baseAppName, String targetAppName, String keywordAttribute, String keywordTargetAttribute, List<String> preResultFilterList, List<String> grayResultFilterList, List<String> prodResultFilterList) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultSummary 开始查询DRM对比分析报告 batchId={0},  baseAppName={1}, targetAppName={2}\\", batchId, baseAppName, targetAppName);\\n\\n        try {\\n            // 分析记录查询\\n            AnalysisRecord analysisRecord = analysisRecordRepository.queryByBatchIdAppName(batchId, baseAppName + \\"_\\" + targetAppName);\\n            if (analysisRecord == null) {\\n                return null;\\n            }\\n\\n            // 查询应用间对比概览（先缓存, 后DB）\\n            List<DrmValuesCmpResultBtwApp> analysisResult = appDrmValueCompareRepository.queryAppDrmValueCmpSummaryBtwApp(analysisRecord.getRecordId(), DrmCompareTypeEnum.BASE_APP_COMPARE_BTW_APP, baseAppName, targetAppName);\\n\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultSummary analysisResult={0}\\", JSON.toJSON(analysisResult));\\n\\n            // 模糊查询\\n            if (!StringUtils.isEmpty(keywordAttribute)) {\\n                return filterAttribute(analysisResult, keywordAttribute, null);\\n            }\\n            if (!StringUtils.isEmpty(keywordTargetAttribute)) {\\n                return filterAttribute(analysisResult, null, keywordTargetAttribute);\\n            }\\n\\n            // 过滤分析结果\\n            return filterResult(analysisResult, preResultFilterList, grayResultFilterList, prodResultFilterList);\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultSummary 查询DRM对比分析结果异常\\");\\n        }\\n        return null;\\n    }\\n\\n    private List<DrmValuesCmpResultBtwApp> filterResult(List<DrmValuesCmpResultBtwApp> analysisResult, List<String> preResultFilterList, List<String> grayResultFilterList, List<String> prodResultFilterList) {\\n        List<DrmValuesCmpResultBtwApp> result = Lists.newArrayList();\\n        for (DrmValuesCmpResultBtwApp item : analysisResult) {\\n            try {\\n                // 分析结果过滤\\n                if (checkFilterList(item, preResultFilterList, grayResultFilterList, prodResultFilterList)) {\\n                    result.add(item);\\n                }\\n            } catch (Exception e) {\\n                LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.filterResult 异常, item={0}\\", JSON.toJSONString(item));\\n            }\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 获取应用间对比明细数据\\n     *\\n     * @param batchId          批次\\n     * @param baseAppName      基线应用\\n     * @param targetAppName    目标应用\\n     * @param baseResourceId   基线资源\\n     * @param targetResourceId 目标资源\\n     * @param baseAttribute    基线属性\\n     * @param targetAttribute  目标属性\\n     * @param baseVersion      基线版本\\n     * @param targetVersion    目标版本\\n     * @return Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp>\\n     */\\n    private Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp> queryBtwDrmCompareResultDetail(String batchId, String baseAppName, String targetAppName, String baseResourceId, String targetResourceId, String baseAttribute, String targetAttribute, String baseVersion, String targetVersion) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultDetail 开始查询DRM对比分析报告 batchId={0}, targetAppName={1}\\", batchId, targetAppName);\\n\\n        try {\\n            // 查询分析记录\\n            AnalysisRecord analysisRecord = analysisRecordRepository.queryByBatchIdAppName(batchId, baseAppName + \\"_\\" + targetAppName);\\n            if (analysisRecord == null) {\\n                return null;\\n            }\\n\\n            Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp> result = appDrmValueCompareRepository.queryAppDrmValueCmpDetailBtwApp(analysisRecord.getRecordId(), DrmCompareTypeEnum.BASE_APP_COMPARE_BTW_APP, baseAppName, targetAppName, baseResourceId, targetResourceId, baseAttribute, targetAttribute, baseVersion, targetVersion);\\n\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultDetail analysisResult={0}\\", JSON.toJSON(result));\\n\\n            return result;\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultDetail 查询DRM对比分析结果异常\\");\\n        }\\n        return null;\\n    }\\n\\n    /**\\n     * 获取应用内对比概览数据\\n     *\\n     * @param batchId          批次\\n     * @param appName          应用名\\n     * @param keywordAttribute 关键词\\n     * @param resultFilterList 分析结果筛选列表\\n     * @return List<AppDrmValuesCompareResultInApp>\\n     */\\n    private List<DrmValuesCompareResultInApp> queryInDrmCompareResultSummary(String batchId, String appName, String keywordAttribute, List<String> resultFilterList) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryInDrmCompareResultSummary 开始查询DRM对比分析报告 batchId={0}, appName={1}\\", batchId, appName);\\n\\n        try {\\n            AnalysisRecord analysisRecord = analysisRecordRepository.queryByBatchIdAppName(batchId, appName);\\n            if (analysisRecord == null) {\\n                return null;\\n            }\\n\\n            List<DrmValuesCompareResultInApp> analysisResult = commonCacheTemplate.execute(new CommonCacheCallback<List<DrmValuesCompareResultInApp>>() {\\n                @Override\\n                public CacheTypeEnum getCacheType() {\\n                    return CacheTypeEnum.DRM_VALUES_COMPARE;\\n                }\\n\\n                @Override\\n                public String buildCacheKey() {\\n                    return DrmUtil.buildSummaryKeyInApp(analysisRecord.getRecordId(), appName);\\n                }\\n\\n                @Override\\n                public List<DrmValuesCompareResultInApp> loadFromExternal() {\\n                    return appDrmValueCompareRepository.queryAppDrmValueCmpSummaryInApp(analysisRecord.getRecordId(), DrmCompareTypeEnum.ENV_COMPARE_IN_APP, appName);\\n                }\\n            });\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryInDrmCompareResultSummary analysisResult={0}\\", JSON.toJSON(analysisResult));\\n\\n\\n            // 模糊查询\\n            if (!StringUtils.isEmpty(keywordAttribute)) {\\n                return analysisResult.stream().filter(analysis -> !StringUtils.isEmpty(analysis.getAttribute()) && analysis.getAttribute().contains(keywordAttribute)).collect(Collectors.toList());\\n            }\\n\\n            // 过滤分析结果\\n            return analysisResult.stream().filter(analysis -> checkFilterList(String.valueOf(analysis.getDrmEnvValuesCompareResultEnum().isType()), resultFilterList)).collect(Collectors.toList());\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.queryInDrmCompareResultSummary 查询DRM对比分析结果异常\\");\\n        }\\n        return null;\\n    }\\n\\n    /**\\n     * 过滤分析结果(相同/不同)\\n     * 包含为TRUE, 不包含为FALSE\\n     *\\n     * @param analysisResult   分析结果\\n     * @param resultFilterList 过滤条件\\n     * @return boolean\\n     */\\n    private boolean checkFilterList(String analysisResult, List<String> resultFilterList) {\\n        return !CollectionUtils.isEmpty(resultFilterList) && resultFilterList.contains(analysisResult);\\n    }\\n\\n    /**\\n     * 获取应用内对比详情数据\\n     *\\n     * @param batchId    批次\\n     * @param appName    应用\\n     * @param resourceId 资源id\\n     * @param attribute  属性\\n     * @param version    版本\\n     * @return Map<EnvTypeEnum, DrmValuesCompareDetailInApp>\\n     */\\n    private Map<EnvTypeEnum, DrmValuesCompareDetailInApp> queryInDrmCompareResultDetail(String batchId, String appName, String resourceId, String attribute, String version) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryInDrmCompareResultDetail 开始查询DRM对比分析报告 batchId={0}, appName={1}\\", batchId, appName);\\n\\n        try {\\n            // 查询分析记录\\n            AnalysisRecord analysisRecord = analysisRecordRepository.queryByBatchIdAppName(batchId, appName);\\n            if (analysisRecord == null) {\\n                return null;\\n            }\\n\\n            Map<EnvTypeEnum, DrmValuesCompareDetailInApp> result = appDrmValueCompareRepository.queryAppDrmValueCmpDetailInApp(analysisRecord.getRecordId(), DrmCompareTypeEnum.ENV_COMPARE_IN_APP, appName, resourceId, attribute, version);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryInDrmCompareResultDetail 查询DRM对比分析报告缓存 result={0}\\", JSON.toJSONString(result));\\n\\n\\n            return result;\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.queryInDrmCompareResultDetail 查询DRM对比分析结果异常\\");\\n        }\\n        return null;\\n    }\\n\\n    /**\\n     * 模糊过滤\\n     *\\n     * @param analysisResult         分析结果\\n     * @param keywordAttribute       基线关键词\\n     * @param keywordTargetAttribute 目标关键词\\n     * @return List<DrmValuesCmpResultBtwApp>\\n     */\\n    private List<DrmValuesCmpResultBtwApp> filterAttribute(List<DrmValuesCmpResultBtwApp> analysisResult, String keywordAttribute, String keywordTargetAttribute) {\\n        if (CollectionUtils.isEmpty(analysisResult)) {\\n            return null;\\n        }\\n        if (StringUtils.isEmpty(keywordAttribute) && StringUtils.isEmpty(keywordTargetAttribute)) {\\n            return analysisResult;\\n        }\\n        List<DrmValuesCmpResultBtwApp> result = Lists.newArrayList();\\n        for (DrmValuesCmpResultBtwApp item : analysisResult) {\\n            if (!StringUtils.isEmpty(keywordAttribute) && !StringUtils.isEmpty(item.getAttribute()) && item.getAttribute().contains(keywordAttribute)) {\\n                result.add(item);\\n            } else if (!StringUtils.isEmpty(keywordTargetAttribute) && !StringUtils.isEmpty(item.getTargetAttribute()) && item.getTargetAttribute().contains(keywordTargetAttribute)) {\\n                result.add(item);\\n            }\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 过滤分析结果(相同/不同)\\n     * 包含为TRUE, 不包含为FALSE\\n     *\\n     * @param analysisResult       分析结果\\n     * @param preResultFilterList  预发过滤条件\\n     * @param grayResultFilterList 灰度过滤条件\\n     * @param prodResultFilterList 生产过滤条件\\n     * @return boolean\\n     */\\n    private boolean checkFilterList(DrmValuesCmpResultBtwApp analysisResult, List<String> preResultFilterList, List<String> grayResultFilterList, List<String> prodResultFilterList) {\\n        Map<EnvTypeEnum, DrmAppEnvValuesCompareResultEnum> envDrmValuesCompareResult = analysisResult.getEnvDrmValuesCompareResult();\\n        if (CollectionUtils.isEmpty(envDrmValuesCompareResult)) {\\n            return false;\\n        }\\n        if (envDrmValuesCompareResult.containsKey(EnvTypeEnum.PRE) && checkFilterList(envDrmValuesCompareResult.get(EnvTypeEnum.PRE).getType().toString(), preResultFilterList)) {\\n            return true;\\n        }\\n        if (envDrmValuesCompareResult.containsKey(EnvTypeEnum.GRAY) && checkFilterList(envDrmValuesCompareResult.get(EnvTypeEnum.GRAY).getType().toString(), grayResultFilterList)) {\\n            return true;\\n        }\\n        if (envDrmValuesCompareResult.containsKey(EnvTypeEnum.PROD) && checkFilterList(envDrmValuesCompareResult.get(EnvTypeEnum.PROD).getType().toString(), prodResultFilterList)) {\\n            return true;\\n        }\\n        return false;\\n    }\\n\\n    /**\\n     * 从缓存, 查询分析结果\\n     *\\n     * @param cacheKey Key\\n     * @return String\\n     */\\n    public Object queryDrmCompareResultCache(String cacheKey) {\\n        return commonCacheTemplate.execute(new CommonCacheCallback<Object>() {\\n            @Override\\n            public CacheTypeEnum getCacheType() {\\n                return CacheTypeEnum.DRM_VALUES_COMPARE;\\n            }\\n\\n            @Override\\n            public String buildCacheKey() {\\n                return cacheKey;\\n            }\\n\\n            @Override\\n            public Object loadFromExternal() {\\n                return null;\\n            }\\n        });\\n    }\\n\\n    /**\\n     * 查询应用推送值数据\\n     * 先缓存\\n     * 查询不到去OPSSLA查询应用下所有DRM资源的推送值\\n     *\\n     * @param batchId      分析批次\\n     * @param appName      应用名\\n     * @param appDrmMOList 应用元数据\\n     * @return boolean\\n     */\\n    public List<DrmValue> queryAppDrmValuesFromCache(String batchId, String appName, List<AppDrmMO> appDrmMOList, Boolean isQueryPlatform) {\\n        return commonCacheTemplate.execute(new CommonCacheCallback<List<DrmValue>>() {\\n            @Override\\n            public CacheTypeEnum getCacheType() {\\n                return CacheTypeEnum.DRM_VALUES_COMPARE;\\n            }\\n\\n            @Override\\n            public String buildCacheKey() {\\n                return batchId + \\"_\\" + appName;\\n            }\\n\\n            @Override\\n            public List<DrmValue> loadFromExternal() {\\n                if (isQueryPlatform) {\\n                    return queryDrmValues(batchId, appName, appDrmMOList);\\n                } else {\\n                    return null;\\n                }\\n            }\\n        });\\n    }\\n\\n    /**\\n     * 从缓存, 查询每个DRM资源的推送值, 查询不到去Opssla平台查询DRM资源的推送值\\n     *\\n     * @param batchId      批次\\n     * @param appName      应用名\\n     * @param appDrmMOList DRM资源\\n     * @return List<DrmValue>\\n     */\\n    private List<DrmValue> queryDrmValues(String batchId, String appName, List<AppDrmMO> appDrmMOList) {\\n        if (CollectionUtils.isEmpty(appDrmMOList)) {\\n            return null;\\n        }\\n\\n        // 01. 查询真实推送值\\n        Map<String, Map<EnvTypeEnum, List<AppDrmZoneValue>>> ravValuesMap = Maps.newHashMap();\\n        for (AppDrmMO appDrmMO : appDrmMOList) {\\n            Map<EnvTypeEnum, List<AppDrmZoneValue>> envZoneValueMap = commonCacheTemplate.execute(new CommonCacheCallback<Map<EnvTypeEnum, List<AppDrmZoneValue>>>() {\\n                @Override\\n                public CacheTypeEnum getCacheType() {\\n                    return CacheTypeEnum.DRM_VALUES_COMPARE;\\n                }\\n\\n                @Override\\n                public String buildCacheKey() {\\n                    return batchId + \\"_\\" + appName + \\"_\\" + appDrmMO.getResourceId() + \\"_\\" + appDrmMO.getResourceDomain() + \\"_\\" + appDrmMO.getResourceVersion() + \\"_\\" + appDrmMO.getAttribute();\\n                }\\n\\n                @Override\\n                public Map<EnvTypeEnum, List<AppDrmZoneValue>> loadFromExternal() {\\n                    AppInfoMO appInfoMO = appInfoRepository.queryByAppName(appName);\\n\\n                    // 查询DRM值，会有三种场景：\\n                    // 1) 返回值NULL, 查不到推送值以及相关zone数据, 未注册drm\\n                    // 2) 返回值有Map, 但是List里面只有null一个值, zone有drm注册, 但未做推送的情况\\n                    // 3) 返回值有Map, List存在非null值, zone有drm注册, 且做了推送\\n                    return appDrmRepository.queryRealTimeDrmValues(null, appDrmMO.getResourceId(), appDrmMO.getResourceDomain(), appDrmMO.getResourceVersion(), appDrmMO.getAttribute(), appInfoMO.getSiteType());\\n                }\\n            });\\n\\n            if (envZoneValueMap != null) {\\n                LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmValuesCompareAnalysisHandler.queryDrmData 查询真实推送值, appDrmMO={0}, envZoneValueMap={1}\\", JSON.toJSONString(appDrmMO), JSON.toJSONString(envZoneValueMap));\\n                ravValuesMap.put(appDrmMO.getResourceId() + \\"_\\" + appDrmMO.getAttribute() + \\"_\\" + appDrmMO.getResourceVersion(), envZoneValueMap);\\n            }\\n        }\\n\\n        // 02. 数据转换\\n        return AppDrmConvertor.convertToDrmValueList(appDrmMOList, ravValuesMap);\\n    }\\n\\n    /**\\n     * 清理缓存\\n     *\\n     * @param batchId 批次Id\\n     * @param appName 应用名\\n     */\\n    public void clearCacheAppDrmValues(String batchId, String appName) {\\n        // 清理应用的DRM推送值\\n        commonCacheService.deleteCache(CacheTypeEnum.DRM_VALUES_COMPARE, batchId + \\"_\\" + appName);\\n\\n        // 查询DRM\\n        List<AppDrmMO> appDrmMOList = appDrmRepository.queryByCondition(Lists.newArrayList(appName), null, null);\\n\\n        // 清理DRM推送值的缓存\\n        for (AppDrmMO appDrmMO : appDrmMOList) {\\n            String key = batchId + \\"_\\" + appName + \\"_\\" + appDrmMO.getResourceId() + \\"_\\" + appDrmMO.getResourceDomain() + \\"_\\" + appDrmMO.getResourceVersion() + \\"_\\" + appDrmMO.getAttribute();\\n            commonCacheService.deleteCache(CacheTypeEnum.DRM_VALUES_COMPARE, key);\\n        }\\n    }\\n\\n    /**\\n     * 查询Drm平台链接\\n     *\\n     * @param appName    应用名\\n     * @param resourceId 资源ID\\n     * @param attribute  属性ID\\n     * @param version    版本\\n     * @return String\\n     */\\n    @Override\\n    public String queryDrmPlatformLink(String appName, String resourceDomain, String resourceId, String attribute, String version) {\\n        // 01. 查询应用\\n        AppInfoMO appInfoMO = appInfoRepository.queryByAppName(appName);\\n        if (appInfoMO == null) {\\n            return \\"\\";\\n        }\\n\\n        // 02. 查询资源\\n        AppDrmMO appDrmMO = appDrmRepository.queryByResourceIdAndAttribute(appName, resourceDomain, resourceId, attribute, version);\\n        if (appDrmMO == null || appDrmMO.getResourcePk() == null || appDrmMO.getAttributePk() == null) {\\n            return \\"\\";\\n        }\\n\\n        // 03. 生成链接\\n        return drmAnalysisService.buildDrmPlatformLink(appDrmMO.getResourcePk(), appDrmMO.getAttributePk(), appInfoMO.getSiteType());\\n    }\\n}","oldCode":"\\n    @Override\\n    public List<AppDrmMO> queryAllDrmByApp(String appName, String dataIdKeyWord) {\\n        // 01. 校验\\n        if (checkIllegalParam(appName)) {\\n            return Lists.newArrayList();\\n        }\\n\\n        // 02. 查询应用DRM数据\\n        List<AppDrmMO> appDrmMOList = appDrmRepository.queryByAppNameList(Lists.newArrayList(appName), dataIdKeyWord);\\n        if (CollectionUtils.isEmpty(appDrmMOList)) {\\n            return Lists.newArrayList();\\n        }\\n        return appDrmMOList;\\n    }","oldFullCode":"/*\\n * Ant Group\\n * Copyright (c) 2004-2022 All Rights Reserved.\\n */\\npackage com.alipay.archcompass.biz.compass.drm;\\n\\nimport com.alibaba.fastjson.JSON;\\nimport com.alipay.archcompass.biz.compass.analysis.BaseAnalysisService;\\nimport com.alipay.archcompass.biz.compass.assets.DrmAnalysisService;\\nimport com.alipay.archcompass.common.util.ArchCompassLogger;\\nimport com.alipay.archcompass.common.util.CollectionUtil;\\nimport com.alipay.archcompass.common.util.DrmUtil;\\nimport com.alipay.archcompass.common.util.LoggerUtil;\\nimport com.alipay.archcompass.core.model.domain.AppDrmMO;\\nimport com.alipay.archcompass.core.model.domain.AppDrmZoneValue;\\nimport com.alipay.archcompass.core.model.domain.AppInfoMO;\\nimport com.alipay.archcompass.core.model.domain.analysis.AnalysisBatch;\\nimport com.alipay.archcompass.core.model.domain.analysis.AnalysisRecord;\\nimport com.alipay.archcompass.core.model.domain.analysis.drm.DrmResourceAttribute;\\nimport com.alipay.archcompass.core.model.domain.analysis.drm.DrmValuesCmpResultBtwApp;\\nimport com.alipay.archcompass.core.model.domain.analysis.drm.DrmValuesCompareResultInApp;\\nimport com.alipay.archcompass.core.model.domain.drm.*;\\nimport com.alipay.archcompass.core.model.enums.*;\\nimport com.alipay.archcompass.core.model.response.PageQueryResult;\\nimport com.alipay.archcompass.core.service.cache.CommonCacheCallback;\\nimport com.alipay.archcompass.core.service.convertor.AppDrmConvertor;\\nimport com.alipay.sofa.runtime.api.annotation.SofaReference;\\nimport com.alipay.sofa.runtime.api.annotation.SofaService;\\nimport com.google.common.collect.Lists;\\nimport com.google.common.collect.Maps;\\nimport org.apache.commons.collections4.ListUtils;\\nimport org.springframework.util.CollectionUtils;\\nimport org.springframework.util.StringUtils;\\n\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.stream.Collectors;\\n\\n/**\\n * @author bue\\n * @version DrmValuesQueryServiceImpl.java, v 0.1 2022年12月02日 10:12 bue\\n */\\n@SofaService\\npublic class DrmAnalysisQueryServiceImpl extends BaseAnalysisService implements DrmAnalysisQueryService {\\n    @SofaReference\\n    private DrmAnalysisService drmAnalysisService;\\n\\n    /**\\n     * 选范围--查询应用下所有的DRM\\n     *\\n     * @param appName 应用名\\n     * @return List\\n     */\\n    @Override\\n    public List<DrmResourceAttribute> queryAppAllDrm(String appName) {\\n        // 01. 入参验证\\n        if (StringUtils.isEmpty(appName)) {\\n            return Lists.newArrayList();\\n        }\\n\\n        // 02. 查询DRM元数据\\n        List<AppDrmMO> appDrmMOList = appDrmRepository.queryByCondition(Lists.newArrayList(appName), null, null);\\n        if (CollectionUtils.isEmpty(appDrmMOList)) {\\n            return Lists.newArrayList();\\n        }\\n\\n        // 03. 生成DRM资源返回值\\n        return AppDrmConvertor.convertToDrmResourceAttributeList(appDrmMOList);\\n    }\\n\\n    /**\\n     * 分析中--查询应用DRM元数据和推送值\\n     *\\n     * @param batchId      分析批次\\n     * @param appName      应用名\\n     * @param appDrmMOList 返回值 元数据\\n     * @param drmValueList 返回值 推送值\\n     * @return Boolean\\n     */\\n    @Override\\n    public boolean queryDrmData(String batchId, String appName, List<AppDrmMO> appDrmMOList, List<DrmValue> drmValueList) {\\n        if (StringUtils.isEmpty(appName)) {\\n            return false;\\n        }\\n        // 查询应用DRM元数据\\n        List<AppDrmMO> appDrmMOs = appDrmRepository.queryByCondition(Lists.newArrayList(appName), null, null);\\n        if (CollectionUtil.isEmpty(appDrmMOs)) {\\n            return true;\\n        }\\n        appDrmMOList.addAll(appDrmMOs);\\n\\n        // 查询应用DRM推送值\\n        List<DrmValue> drmValues = queryAppDrmValuesFromCache(batchId, appName, appDrmMOList, true);\\n        if (CollectionUtil.isEmpty(drmValues)) {\\n            return true;\\n        }\\n        drmValueList.addAll(drmValues);\\n        return true;\\n    }\\n\\n    /**\\n     * 看分析--查询DRM对比分析状态\\n     *\\n     * @param batchId 批次\\n     * @return AnalysisStatusEnum\\n     */\\n    @Override\\n    public AnalysisStatusEnum queryDrmCompareAnalysisStatus(String batchId) {\\n        AnalysisBatch analysisBatch = analysisBatchRepository.queryByBatchId(batchId);\\n        if (analysisBatch == null || !analysisBatch.getBatchStatus().equals(AnalysisBatchStatusEnum.COMPLETED)) {\\n            // 无分析记录, 返回待分析\\n            return AnalysisStatusEnum.PROCESSING;\\n        }\\n        List<AnalysisRecord> analysisRecordList = analysisRecordRepository.queryByBatchId(batchId);\\n        if (CollectionUtils.isEmpty(analysisRecordList)) {\\n            // 有分析记录, 返回待分析\\n            return AnalysisStatusEnum.PROCESSING;\\n        }\\n        for (AnalysisRecord analysisRecord : analysisRecordList) {\\n            switch (analysisRecord.getStatus()) {\\n                case FAILED:\\n                    return AnalysisStatusEnum.FAILED;\\n                case PROCESSING:\\n                    return AnalysisStatusEnum.PROCESSING;\\n                case INIT:\\n                    return AnalysisStatusEnum.INIT;\\n                case RETRY:\\n                    return AnalysisStatusEnum.RETRY;\\n                default:\\n                    break;\\n            }\\n        }\\n        return AnalysisStatusEnum.COMPLETED;\\n    }\\n\\n    /**\\n     * 看分析--应用内--对比概览（分页）\\n     *\\n     * @param batchId          批次号\\n     * @param appName          应用名\\n     * @param currentPage      当前页\\n     * @param pageSize         页大小\\n     * @param resultFilterList 分析结果筛选列表\\n     * @return DrmValuesCompareSummaryInApp\\n     */\\n    @Override\\n    public DrmValuesCompareSummaryInApp queryDrmCompareSummaryPageInApp(String batchId, String appName, int currentPage, int pageSize, String keywordAttribute, List<String> resultFilterList) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageInApp 开始查询应用内对比概览 batchId={0}, appName={1}, currentPage={2}, pageSize={3}\\", batchId, appName, currentPage, pageSize);\\n\\n        DrmValuesCompareSummaryInApp drmValuesCompareSummaryInApp = new DrmValuesCompareSummaryInApp(0, currentPage, pageSize, batchId, appName, Lists.newArrayList());\\n        try {\\n\\n            // 02. 获取应用内对比数据\\n            List<DrmValuesCompareResultInApp> appDrmValuesCompareInApp = queryInDrmCompareResultSummary(batchId, appName, keywordAttribute, resultFilterList);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageInApp 获取应用内对比数据 appDrmValuesCompareInApp={0}\\", JSON.toJSON(appDrmValuesCompareInApp));\\n            if (CollectionUtils.isEmpty(appDrmValuesCompareInApp)) {\\n                // 没查到存在DRM分析结果, 默认返回全空数据\\n                return drmValuesCompareSummaryInApp;\\n            }\\n\\n            // 03. 分页 && 聚合数据\\n            List<DrmValuesCompareSummaryUnitInApp> summary = Lists.newArrayList();\\n            int pageCount = 0;\\n            if (!CollectionUtils.isEmpty(appDrmValuesCompareInApp)) {\\n                // 分页\\n                List<List<DrmValuesCompareResultInApp>> pageList = ListUtils.partition(appDrmValuesCompareInApp, pageSize);\\n                PageQueryResult<List<DrmValuesCompareResultInApp>> pageQueryResult = new PageQueryResult<>();\\n                pageQueryResult.setResult(pageList.get(currentPage - 1));\\n                pageQueryResult.setCurrentPage(currentPage);\\n                pageQueryResult.setPageSize(pageSize);\\n                pageQueryResult.setTotal(appDrmValuesCompareInApp.size());\\n\\n                pageCount = pageQueryResult.getTotal();\\n                summary = AppDrmConvertor.convertToDrmValuesCompareUnitInApp(pageQueryResult.getResult());\\n            }\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageInApp 分页 && 聚合数据 summary={0}\\", JSON.toJSON(summary));\\n\\n            // 04. 组装返回值\\n            drmValuesCompareSummaryInApp.setAppName(appName);\\n            drmValuesCompareSummaryInApp.setBatchId(batchId);\\n            drmValuesCompareSummaryInApp.setPageCount(pageCount);\\n            drmValuesCompareSummaryInApp.setPageSize(pageSize);\\n            drmValuesCompareSummaryInApp.setCurrentPage(currentPage);\\n            drmValuesCompareSummaryInApp.setSummary(summary);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageInApp 组装返回值 drmValuesCompareSummaryInApp={0}\\", JSON.toJSON(drmValuesCompareSummaryInApp));\\n\\n            return drmValuesCompareSummaryInApp;\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"queryDrmCompareSummaryPageInApp 查询异常, batchId={0}, appName={1}\\", batchId, appName);\\n        }\\n        return drmValuesCompareSummaryInApp;\\n    }\\n\\n    /**\\n     * 看分析--应用内--对比详情\\n     *\\n     * @param batchId    批次号\\n     * @param appName    应用名\\n     * @param resourceId 资源\\n     * @param attribute  属性\\n     * @param version    版本\\n     * @return Map<EnvTypeEnum, DrmValuesCompareDetailInApp>\\n     */\\n    @Override\\n    public Map<EnvTypeEnum, DrmValuesCompareDetailInApp> queryDrmCompareDetailInApp(String batchId, String appName, String resourceId, String attribute, String version) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareDetailInApp 开始查询应用内对比详情 batchId={0}, appName={1}, resourceId={2}, attribute={3}, version={4}\\", batchId, appName, resourceId, attribute, version);\\n\\n        Map<EnvTypeEnum, DrmValuesCompareDetailInApp> result = Maps.newHashMap();\\n        try {\\n            result = queryInDrmCompareResultDetail(batchId, appName, resourceId, attribute, version);\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"queryDrmCompareDetailInApp 查询异常, batchId={0}, appName={1}\\", batchId, appName);\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 看分析--应用间--对比概览（分页）\\n     *\\n     * @param batchId                批次号\\n     * @param baseAppName            基线应用名\\n     * @param targetAppName          目标应用名\\n     * @param currentPage            当前页\\n     * @param pageSize               页大小\\n     * @param keywordAttribute       基线属性关键词\\n     * @param keywordTargetAttribute 目标属性关键词\\n     * @param preResultFilterList    预发分析结果过滤条件\\n     * @param grayResultFilterList   灰度分析结果过滤条件\\n     * @param prodResultFilterList   生产分析结果过滤条件\\n     * @return DrmValuesCompareSummaryBetweenApp\\n     */\\n    @Override\\n    public DrmValuesCompareSummaryBetweenApp queryDrmCompareSummaryPageBetweenApp(String batchId, String baseAppName, String targetAppName, int currentPage, int pageSize, String keywordAttribute, String keywordTargetAttribute, List<String> preResultFilterList, List<String> grayResultFilterList, List<String> prodResultFilterList) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageBetweenApp 开始查询应用间对比概览 batchId={0}, baseAppName={1}, targetAppName={2}, currentPage={3}, pageSize={4}\\", batchId, baseAppName, targetAppName, currentPage, pageSize);\\n\\n        DrmValuesCompareSummaryBetweenApp result = new DrmValuesCompareSummaryBetweenApp(0, currentPage, pageSize, batchId, baseAppName, targetAppName, Lists.newArrayList());\\n        try {\\n            // 02. 获取应用间对比数据\\n            List<DrmValuesCmpResultBtwApp> appDrmValuesCompareBetweenApp = queryBtwDrmCompareResultSummary(batchId, baseAppName, targetAppName, keywordAttribute, keywordTargetAttribute, preResultFilterList, grayResultFilterList, prodResultFilterList);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageBetweenApp 获取应用间对比数据 appDrmValuesCompareBetweenApp={0}\\", JSON.toJSON(appDrmValuesCompareBetweenApp));\\n\\n            // 03. 分页 && 聚合数据\\n            List<DrmValuesCompareSummaryUnitBetweenApp> summary = Lists.newArrayList();\\n            int pageCount = 0;\\n            if (!CollectionUtils.isEmpty(appDrmValuesCompareBetweenApp)) {\\n                appDrmValuesCompareBetweenApp.sort((o1, o2) -> {\\n                    int drmCount1 = 0;\\n                    int drmCount2 = 0;\\n                    if (!StringUtils.isEmpty(o1.getAttribute())) {\\n                        drmCount1++;\\n                    }\\n                    if (!StringUtils.isEmpty(o1.getTargetAttribute())) {\\n                        drmCount1++;\\n                    }\\n                    if (!StringUtils.isEmpty(o2.getAttribute())) {\\n                        drmCount2++;\\n                    }\\n                    if (!StringUtils.isEmpty(o2.getTargetAttribute())) {\\n                        drmCount2++;\\n                    }\\n                    if (drmCount1 > drmCount2) {\\n                        return -1;\\n                    } else if (drmCount1 < drmCount2) {\\n                        return 1;\\n                    } else if (drmCount1 == 2) {\\n                        return o1.getAttribute().compareToIgnoreCase(o2.getAttribute());\\n                    } else if (drmCount1 == 1) {\\n                        if (StringUtils.isEmpty(o1.getAttribute()) && !StringUtils.isEmpty(o2.getAttribute())) {\\n                            return 1;\\n                        } else if (!StringUtils.isEmpty(o1.getAttribute()) && StringUtils.isEmpty(o2.getAttribute())) {\\n                            return -1;\\n                        } else if (!StringUtils.isEmpty(o1.getAttribute()) && !StringUtils.isEmpty(o2.getAttribute())) {\\n                            return o1.getAttribute().compareToIgnoreCase(o2.getAttribute());\\n                        } else {\\n                            return o1.getTargetAttribute().compareToIgnoreCase(o2.getTargetAttribute());\\n                        }\\n                    } else {\\n                        return 0;\\n                    }\\n                });\\n                List<List<DrmValuesCmpResultBtwApp>> pageList = ListUtils.partition(appDrmValuesCompareBetweenApp, pageSize);\\n                PageQueryResult<List<DrmValuesCmpResultBtwApp>> pageQueryResult = new PageQueryResult<>();\\n                pageQueryResult.setResult(pageList.get(currentPage - 1));\\n                pageQueryResult.setCurrentPage(currentPage);\\n                pageQueryResult.setPageSize(pageSize);\\n                pageQueryResult.setTotal(appDrmValuesCompareBetweenApp.size());\\n\\n                pageCount = pageQueryResult.getTotal();\\n                summary = AppDrmConvertor.convertToDrmValuesCompareUnitBetweenApp(pageQueryResult.getResult());\\n            }\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageBetweenApp 分页 && 聚合数据 summary={0}\\", JSON.toJSON(summary));\\n\\n\\n            // 04. 组装返回值\\n            result.setBaseAppName(targetAppName);\\n            result.setBatchId(batchId);\\n            result.setPageCount(pageCount);\\n            result.setPageSize(pageSize);\\n            result.setCurrentPage(currentPage);\\n            result.setSummary(summary);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareSummaryPageBetweenApp 组装返回值 result={0}\\", JSON.toJSON(result));\\n\\n            return result;\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"queryDrmCompareSummaryPageBetweenApp 查询异常, batchId={0}, baseAppName={1}, targetAppName={2}\\", batchId, baseAppName, targetAppName);\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 看分析--应用间--对比详情\\n     *\\n     * @param batchId       批次号\\n     * @param baseAppName   基线应用\\n     * @param targetAppName 目标应用\\n     * @return DrmValuesCompareDetailBetweenApp\\n     */\\n    @Override\\n    public Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp> queryDrmCompareDetailBetweenApp(String batchId, String baseAppName, String targetAppName, String baseResourceId, String targetResourceId, String baseAttribute, String targetAttribute, String baseVersion, String targetVersion) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"queryDrmCompareDetailBetweenApp 开始查询应用内对比详情 batchId={0}, baseAppName={1}, targetAppName={2}, baseResourceId={3}, targetResourceId={4}, baseAttribute={5}, targetAttribute={6}, baseVersion={7}, targetVersion={8}\\", batchId, baseAppName, targetAppName, baseResourceId, targetResourceId, baseAttribute, targetAttribute, baseVersion, targetVersion);\\n\\n        Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp> result = Maps.newHashMap();\\n        try {\\n            result = queryBtwDrmCompareResultDetail(batchId, baseAppName, targetAppName, baseResourceId, targetResourceId, baseAttribute, targetAttribute, baseVersion, targetVersion);\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"queryDrmCompareDetailBetweenApp 查询异常, batchId={0}, baseAppName={1}, targetAppName={2}\\", batchId, baseAppName, targetAppName);\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 获取应用间对比概览数据\\n     *\\n     * @param batchId                批次\\n     * @param baseAppName            基线应用\\n     * @param targetAppName          目标应用\\n     * @param keywordAttribute       基线attribute关键词\\n     * @param keywordTargetAttribute 目标attribute关键词\\n     * @param preResultFilterList    预发分析结果过滤条件\\n     * @param grayResultFilterList   灰度分析结果过滤条件\\n     * @param prodResultFilterList   生产分析结果过滤条件\\n     * @return List<AppDrmValuesCompareResultBetweenApp>\\n     */\\n    private List<DrmValuesCmpResultBtwApp> queryBtwDrmCompareResultSummary(String batchId, String baseAppName, String targetAppName, String keywordAttribute, String keywordTargetAttribute, List<String> preResultFilterList, List<String> grayResultFilterList, List<String> prodResultFilterList) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultSummary 开始查询DRM对比分析报告 batchId={0},  baseAppName={1}, targetAppName={2}\\", batchId, baseAppName, targetAppName);\\n\\n        try {\\n            // 分析记录查询\\n            AnalysisRecord analysisRecord = analysisRecordRepository.queryByBatchIdAppName(batchId, baseAppName + \\"_\\" + targetAppName);\\n            if (analysisRecord == null) {\\n                return null;\\n            }\\n\\n            // 查询应用间对比概览（先缓存, 后DB）\\n            List<DrmValuesCmpResultBtwApp> analysisResult = appDrmValueCompareRepository.queryAppDrmValueCmpSummaryBtwApp(analysisRecord.getRecordId(), DrmCompareTypeEnum.BASE_APP_COMPARE_BTW_APP, baseAppName, targetAppName);\\n\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultSummary analysisResult={0}\\", JSON.toJSON(analysisResult));\\n\\n            // 模糊查询\\n            if (!StringUtils.isEmpty(keywordAttribute)) {\\n                return filterAttribute(analysisResult, keywordAttribute, null);\\n            }\\n            if (!StringUtils.isEmpty(keywordTargetAttribute)) {\\n                return filterAttribute(analysisResult, null, keywordTargetAttribute);\\n            }\\n\\n            // 过滤分析结果\\n            return filterResult(analysisResult, preResultFilterList, grayResultFilterList, prodResultFilterList);\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultSummary 查询DRM对比分析结果异常\\");\\n        }\\n        return null;\\n    }\\n\\n    private List<DrmValuesCmpResultBtwApp> filterResult(List<DrmValuesCmpResultBtwApp> analysisResult, List<String> preResultFilterList, List<String> grayResultFilterList, List<String> prodResultFilterList) {\\n        List<DrmValuesCmpResultBtwApp> result = Lists.newArrayList();\\n        for (DrmValuesCmpResultBtwApp item : analysisResult) {\\n            try {\\n                // 分析结果过滤\\n                if (checkFilterList(item, preResultFilterList, grayResultFilterList, prodResultFilterList)) {\\n                    result.add(item);\\n                }\\n            } catch (Exception e) {\\n                LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.filterResult 异常, item={0}\\", JSON.toJSONString(item));\\n            }\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 获取应用间对比明细数据\\n     *\\n     * @param batchId          批次\\n     * @param baseAppName      基线应用\\n     * @param targetAppName    目标应用\\n     * @param baseResourceId   基线资源\\n     * @param targetResourceId 目标资源\\n     * @param baseAttribute    基线属性\\n     * @param targetAttribute  目标属性\\n     * @param baseVersion      基线版本\\n     * @param targetVersion    目标版本\\n     * @return Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp>\\n     */\\n    private Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp> queryBtwDrmCompareResultDetail(String batchId, String baseAppName, String targetAppName, String baseResourceId, String targetResourceId, String baseAttribute, String targetAttribute, String baseVersion, String targetVersion) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultDetail 开始查询DRM对比分析报告 batchId={0}, targetAppName={1}\\", batchId, targetAppName);\\n\\n        try {\\n            // 查询分析记录\\n            AnalysisRecord analysisRecord = analysisRecordRepository.queryByBatchIdAppName(batchId, baseAppName + \\"_\\" + targetAppName);\\n            if (analysisRecord == null) {\\n                return null;\\n            }\\n\\n            Map<EnvTypeEnum, DrmValuesCompareDetailBetweenApp> result = appDrmValueCompareRepository.queryAppDrmValueCmpDetailBtwApp(analysisRecord.getRecordId(), DrmCompareTypeEnum.BASE_APP_COMPARE_BTW_APP, baseAppName, targetAppName, baseResourceId, targetResourceId, baseAttribute, targetAttribute, baseVersion, targetVersion);\\n\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultDetail analysisResult={0}\\", JSON.toJSON(result));\\n\\n            return result;\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.queryBtwDrmCompareResultDetail 查询DRM对比分析结果异常\\");\\n        }\\n        return null;\\n    }\\n\\n    /**\\n     * 获取应用内对比概览数据\\n     *\\n     * @param batchId          批次\\n     * @param appName          应用名\\n     * @param keywordAttribute 关键词\\n     * @param resultFilterList 分析结果筛选列表\\n     * @return List<AppDrmValuesCompareResultInApp>\\n     */\\n    private List<DrmValuesCompareResultInApp> queryInDrmCompareResultSummary(String batchId, String appName, String keywordAttribute, List<String> resultFilterList) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryInDrmCompareResultSummary 开始查询DRM对比分析报告 batchId={0}, appName={1}\\", batchId, appName);\\n\\n        try {\\n            AnalysisRecord analysisRecord = analysisRecordRepository.queryByBatchIdAppName(batchId, appName);\\n            if (analysisRecord == null) {\\n                return null;\\n            }\\n\\n            List<DrmValuesCompareResultInApp> analysisResult = commonCacheTemplate.execute(new CommonCacheCallback<List<DrmValuesCompareResultInApp>>() {\\n                @Override\\n                public CacheTypeEnum getCacheType() {\\n                    return CacheTypeEnum.DRM_VALUES_COMPARE;\\n                }\\n\\n                @Override\\n                public String buildCacheKey() {\\n                    return DrmUtil.buildSummaryKeyInApp(analysisRecord.getRecordId(), appName);\\n                }\\n\\n                @Override\\n                public List<DrmValuesCompareResultInApp> loadFromExternal() {\\n                    return appDrmValueCompareRepository.queryAppDrmValueCmpSummaryInApp(analysisRecord.getRecordId(), DrmCompareTypeEnum.ENV_COMPARE_IN_APP, appName);\\n                }\\n            });\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryInDrmCompareResultSummary analysisResult={0}\\", JSON.toJSON(analysisResult));\\n\\n\\n            // 模糊查询\\n            if (!StringUtils.isEmpty(keywordAttribute)) {\\n                return analysisResult.stream().filter(analysis -> !StringUtils.isEmpty(analysis.getAttribute()) && analysis.getAttribute().contains(keywordAttribute)).collect(Collectors.toList());\\n            }\\n\\n            // 过滤分析结果\\n            return analysisResult.stream().filter(analysis -> checkFilterList(String.valueOf(analysis.getDrmEnvValuesCompareResultEnum().isType()), resultFilterList)).collect(Collectors.toList());\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.queryInDrmCompareResultSummary 查询DRM对比分析结果异常\\");\\n        }\\n        return null;\\n    }\\n\\n    /**\\n     * 过滤分析结果(相同/不同)\\n     * 包含为TRUE, 不包含为FALSE\\n     *\\n     * @param analysisResult   分析结果\\n     * @param resultFilterList 过滤条件\\n     * @return boolean\\n     */\\n    private boolean checkFilterList(String analysisResult, List<String> resultFilterList) {\\n        return !CollectionUtils.isEmpty(resultFilterList) && resultFilterList.contains(analysisResult);\\n    }\\n\\n    /**\\n     * 获取应用内对比详情数据\\n     *\\n     * @param batchId    批次\\n     * @param appName    应用\\n     * @param resourceId 资源id\\n     * @param attribute  属性\\n     * @param version    版本\\n     * @return Map<EnvTypeEnum, DrmValuesCompareDetailInApp>\\n     */\\n    private Map<EnvTypeEnum, DrmValuesCompareDetailInApp> queryInDrmCompareResultDetail(String batchId, String appName, String resourceId, String attribute, String version) {\\n        LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryInDrmCompareResultDetail 开始查询DRM对比分析报告 batchId={0}, appName={1}\\", batchId, appName);\\n\\n        try {\\n            // 查询分析记录\\n            AnalysisRecord analysisRecord = analysisRecordRepository.queryByBatchIdAppName(batchId, appName);\\n            if (analysisRecord == null) {\\n                return null;\\n            }\\n\\n            Map<EnvTypeEnum, DrmValuesCompareDetailInApp> result = appDrmValueCompareRepository.queryAppDrmValueCmpDetailInApp(analysisRecord.getRecordId(), DrmCompareTypeEnum.ENV_COMPARE_IN_APP, appName, resourceId, attribute, version);\\n            LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmAnalysisQueryService.queryInDrmCompareResultDetail 查询DRM对比分析报告缓存 result={0}\\", JSON.toJSONString(result));\\n\\n\\n            return result;\\n        } catch (Exception e) {\\n            LoggerUtil.error(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, e, \\"DrmAnalysisQueryService.queryInDrmCompareResultDetail 查询DRM对比分析结果异常\\");\\n        }\\n        return null;\\n    }\\n\\n    /**\\n     * 模糊过滤\\n     *\\n     * @param analysisResult         分析结果\\n     * @param keywordAttribute       基线关键词\\n     * @param keywordTargetAttribute 目标关键词\\n     * @return List<DrmValuesCmpResultBtwApp>\\n     */\\n    private List<DrmValuesCmpResultBtwApp> filterAttribute(List<DrmValuesCmpResultBtwApp> analysisResult, String keywordAttribute, String keywordTargetAttribute) {\\n        if (CollectionUtils.isEmpty(analysisResult)) {\\n            return null;\\n        }\\n        if (StringUtils.isEmpty(keywordAttribute) && StringUtils.isEmpty(keywordTargetAttribute)) {\\n            return analysisResult;\\n        }\\n        List<DrmValuesCmpResultBtwApp> result = Lists.newArrayList();\\n        for (DrmValuesCmpResultBtwApp item : analysisResult) {\\n            if (!StringUtils.isEmpty(keywordAttribute) && !StringUtils.isEmpty(item.getAttribute()) && item.getAttribute().contains(keywordAttribute)) {\\n                result.add(item);\\n            } else if (!StringUtils.isEmpty(keywordTargetAttribute) && !StringUtils.isEmpty(item.getTargetAttribute()) && item.getTargetAttribute().contains(keywordTargetAttribute)) {\\n                result.add(item);\\n            }\\n        }\\n        return result;\\n    }\\n\\n    /**\\n     * 过滤分析结果(相同/不同)\\n     * 包含为TRUE, 不包含为FALSE\\n     *\\n     * @param analysisResult       分析结果\\n     * @param preResultFilterList  预发过滤条件\\n     * @param grayResultFilterList 灰度过滤条件\\n     * @param prodResultFilterList 生产过滤条件\\n     * @return boolean\\n     */\\n    private boolean checkFilterList(DrmValuesCmpResultBtwApp analysisResult, List<String> preResultFilterList, List<String> grayResultFilterList, List<String> prodResultFilterList) {\\n        Map<EnvTypeEnum, DrmAppEnvValuesCompareResultEnum> envDrmValuesCompareResult = analysisResult.getEnvDrmValuesCompareResult();\\n        if (CollectionUtils.isEmpty(envDrmValuesCompareResult)) {\\n            return false;\\n        }\\n        if (envDrmValuesCompareResult.containsKey(EnvTypeEnum.PRE) && checkFilterList(envDrmValuesCompareResult.get(EnvTypeEnum.PRE).getType().toString(), preResultFilterList)) {\\n            return true;\\n        }\\n        if (envDrmValuesCompareResult.containsKey(EnvTypeEnum.GRAY) && checkFilterList(envDrmValuesCompareResult.get(EnvTypeEnum.GRAY).getType().toString(), grayResultFilterList)) {\\n            return true;\\n        }\\n        if (envDrmValuesCompareResult.containsKey(EnvTypeEnum.PROD) && checkFilterList(envDrmValuesCompareResult.get(EnvTypeEnum.PROD).getType().toString(), prodResultFilterList)) {\\n            return true;\\n        }\\n        return false;\\n    }\\n\\n    /**\\n     * 从缓存, 查询分析结果\\n     *\\n     * @param cacheKey Key\\n     * @return String\\n     */\\n    public Object queryDrmCompareResultCache(String cacheKey) {\\n        return commonCacheTemplate.execute(new CommonCacheCallback<Object>() {\\n            @Override\\n            public CacheTypeEnum getCacheType() {\\n                return CacheTypeEnum.DRM_VALUES_COMPARE;\\n            }\\n\\n            @Override\\n            public String buildCacheKey() {\\n                return cacheKey;\\n            }\\n\\n            @Override\\n            public Object loadFromExternal() {\\n                return null;\\n            }\\n        });\\n    }\\n\\n    /**\\n     * 查询应用推送值数据\\n     * 先缓存\\n     * 查询不到去OPSSLA查询应用下所有DRM资源的推送值\\n     *\\n     * @param batchId      分析批次\\n     * @param appName      应用名\\n     * @param appDrmMOList 应用元数据\\n     * @return boolean\\n     */\\n    public List<DrmValue> queryAppDrmValuesFromCache(String batchId, String appName, List<AppDrmMO> appDrmMOList, Boolean isQueryPlatform) {\\n        return commonCacheTemplate.execute(new CommonCacheCallback<List<DrmValue>>() {\\n            @Override\\n            public CacheTypeEnum getCacheType() {\\n                return CacheTypeEnum.DRM_VALUES_COMPARE;\\n            }\\n\\n            @Override\\n            public String buildCacheKey() {\\n                return batchId + \\"_\\" + appName;\\n            }\\n\\n            @Override\\n            public List<DrmValue> loadFromExternal() {\\n                if (isQueryPlatform) {\\n                    return queryDrmValues(batchId, appName, appDrmMOList);\\n                } else {\\n                    return null;\\n                }\\n            }\\n        });\\n    }\\n\\n    /**\\n     * 从缓存, 查询每个DRM资源的推送值, 查询不到去Opssla平台查询DRM资源的推送值\\n     *\\n     * @param batchId      批次\\n     * @param appName      应用名\\n     * @param appDrmMOList DRM资源\\n     * @return List<DrmValue>\\n     */\\n    private List<DrmValue> queryDrmValues(String batchId, String appName, List<AppDrmMO> appDrmMOList) {\\n        if (CollectionUtils.isEmpty(appDrmMOList)) {\\n            return null;\\n        }\\n\\n        // 01. 查询真实推送值\\n        Map<String, Map<EnvTypeEnum, List<AppDrmZoneValue>>> ravValuesMap = Maps.newHashMap();\\n        for (AppDrmMO appDrmMO : appDrmMOList) {\\n            Map<EnvTypeEnum, List<AppDrmZoneValue>> envZoneValueMap = commonCacheTemplate.execute(new CommonCacheCallback<Map<EnvTypeEnum, List<AppDrmZoneValue>>>() {\\n                @Override\\n                public CacheTypeEnum getCacheType() {\\n                    return CacheTypeEnum.DRM_VALUES_COMPARE;\\n                }\\n\\n                @Override\\n                public String buildCacheKey() {\\n                    return batchId + \\"_\\" + appName + \\"_\\" + appDrmMO.getResourceId() + \\"_\\" + appDrmMO.getResourceDomain() + \\"_\\" + appDrmMO.getResourceVersion() + \\"_\\" + appDrmMO.getAttribute();\\n                }\\n\\n                @Override\\n                public Map<EnvTypeEnum, List<AppDrmZoneValue>> loadFromExternal() {\\n                    AppInfoMO appInfoMO = appInfoRepository.queryByAppName(appName);\\n\\n                    // 查询DRM值，会有三种场景：\\n                    // 1) 返回值NULL, 查不到推送值以及相关zone数据, 未注册drm\\n                    // 2) 返回值有Map, 但是List里面只有null一个值, zone有drm注册, 但未做推送的情况\\n                    // 3) 返回值有Map, List存在非null值, zone有drm注册, 且做了推送\\n                    return appDrmRepository.queryRealTimeDrmValues(null, appDrmMO.getResourceId(), appDrmMO.getResourceDomain(), appDrmMO.getResourceVersion(), appDrmMO.getAttribute(), appInfoMO.getSiteType());\\n                }\\n            });\\n\\n            if (envZoneValueMap != null) {\\n                LoggerUtil.info(ArchCompassLogger.ARCH_COMPASS_BIZ_LOGGER, \\"DrmValuesCompareAnalysisHandler.queryDrmData 查询真实推送值, appDrmMO={0}, envZoneValueMap={1}\\", JSON.toJSONString(appDrmMO), JSON.toJSONString(envZoneValueMap));\\n                ravValuesMap.put(appDrmMO.getResourceId() + \\"_\\" + appDrmMO.getAttribute() + \\"_\\" + appDrmMO.getResourceVersion(), envZoneValueMap);\\n            }\\n        }\\n\\n        // 02. 数据转换\\n        return AppDrmConvertor.convertToDrmValueList(appDrmMOList, ravValuesMap);\\n    }\\n\\n    /**\\n     * 清理缓存\\n     *\\n     * @param batchId 批次Id\\n     * @param appName 应用名\\n     */\\n    public void clearCacheAppDrmValues(String batchId, String appName) {\\n        // 清理应用的DRM推送值\\n        commonCacheService.deleteCache(CacheTypeEnum.DRM_VALUES_COMPARE, batchId + \\"_\\" + appName);\\n\\n        // 查询DRM\\n        List<AppDrmMO> appDrmMOList = appDrmRepository.queryByCondition(Lists.newArrayList(appName), null, null);\\n\\n        // 清理DRM推送值的缓存\\n        for (AppDrmMO appDrmMO : appDrmMOList) {\\n            String key = batchId + \\"_\\" + appName + \\"_\\" + appDrmMO.getResourceId() + \\"_\\" + appDrmMO.getResourceDomain() + \\"_\\" + appDrmMO.getResourceVersion() + \\"_\\" + appDrmMO.getAttribute();\\n            commonCacheService.deleteCache(CacheTypeEnum.DRM_VALUES_COMPARE, key);\\n        }\\n    }\\n\\n    /**\\n     * 查询Drm平台链接\\n     *\\n     * @param appName    应用名\\n     * @param resourceId 资源ID\\n     * @param attribute  属性ID\\n     * @param version    版本\\n     * @return String\\n     */\\n    @Override\\n    public String queryDrmPlatformLink(String appName, String resourceDomain, String resourceId, String attribute, String version) {\\n        // 01. 查询应用\\n        AppInfoMO appInfoMO = appInfoRepository.queryByAppName(appName);\\n        if (appInfoMO == null) {\\n            return \\"\\";\\n        }\\n\\n        // 02. 查询资源\\n        AppDrmMO appDrmMO = appDrmRepository.queryByResourceIdAndAttribute(appName, resourceDomain, resourceId, attribute, version);\\n        if (appDrmMO == null || appDrmMO.getResourcePk() == null || appDrmMO.getAttributePk() == null) {\\n            return \\"\\";\\n        }\\n\\n        // 03. 生成链接\\n        return drmAnalysisService.buildDrmPlatformLink(appDrmMO.getResourcePk(), appDrmMO.getAttributePk(), appInfoMO.getSiteType());\\n    }\\n}","type":"M"}]',
      'gmtCreate': '2024-07-18T08:03:56.000+00:00',
      'gmtModified': '2024-07-19T09:37:29.000+00:00',
      'taskId': '203092039200454545454',
      'instanceId': '1',
    },
    {
      'id': 100007,
      'nodeInstanceId': '1',
      'flowItem': 'GENERATE_STEP',
      'flowItemName': '生成步骤',
      'flowStatus': 'COMPLETED',
      'flowContent':
        '[{"filePath":"app/web/src/main/java/com/alipay/archcompass/web/controller/invalidanalysis/DrmQueryController.java","id":"0","step":"移除queryInvalidDrmTree方法中对invalidFlag参数的判断逻辑，相关条件不再根据invalidFlag设置。222","type":"M"},{"filePath":"app/biz/compass/src/main/java/com/alipay/archcompass/biz/compass/drm/DrmAnalysisQueryServiceImpl.java","id":"3","step":"检查并移除与flag参数相关的判断逻辑，如果存在。444","type":"M"},{"id":1721388290733,"filePath":"src/components/Common/index.js","step":"22132","type":"A"}]',
      'gmtCreate': '2024-07-18T06:18:08.000+00:00',
      'gmtModified': '2024-07-19T11:24:51.000+00:00',
      'taskId': '203092039200454545454',
      'instanceId': null,
    },
  ],
};

const remoteData = JSON.parse(remote.data[0].flowContent);
console.log(`🚀 ~ remoteData:`, remoteData);

const parsed = remoteData.map((item) => {
  return {
    path: item.filePath,
    oldCode: item.oldFullCode,
    newCode: item.newFullCode,
  };
});
console.log(`🚀 ~ parsed ~ parsed:`, parsed);

export { parsed };
